fortutf

FORTRAN Unit Test Suite written in FORTRAN

https://github.com/artemis-beta/fortutf

Science Score: 54.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
    1 of 5 committers (20.0%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (15.0%) to scientific vocabulary

Keywords

fortran test test-framework testing-fortran unit-testing
Last synced: 6 months ago · JSON representation ·

Repository

FORTRAN Unit Test Suite written in FORTRAN

Basic Info
Statistics
  • Stars: 11
  • Watchers: 2
  • Forks: 4
  • Open Issues: 4
  • Releases: 5
Topics
fortran test test-framework testing-fortran unit-testing
Created about 5 years ago · Last pushed about 1 year ago
Metadata Files
Readme Changelog License Citation

README.md

FORTRAN Unit Test Framework

A purely FORTRANic framework for testing FORTRAN code

FortUTF Ubuntu GFortran 13 FortUTF Windows GFortran 13 FortUTF macOS GFortran 13

FortUTF Ubuntu Intel 2025 FortUTF Ubuntu lfortran 0.33.0

codecov

NOTE: As of v0.1.4-alpha a GFortran compiler supporting FORTRAN-2008 is required for test run command line arguments.

NOTE: Currently FortUTF does not support lfortran

Introduction

FortUTF is Unit Test framework written purely in FORTRAN to be compatible with as many projects as possible, the basis for the test suite is template scripts constructed within CMake during configuration. The framework is still in development so documentation is limited, but I promise once it is complete documentation will be a priority. For now I will introduce the basics.

Writing Tests

All assertions in the current state can be found in the file src/assertions.f90. To write a test you only need to create a file containing one a subroutine for each test you wish to run. You can use the available macro script contained within FortUTF which will construct a main script to build and run the tests.

Example Project

Contained within this repository is an example project which demonstrates usage of the framework in the form:

bash demo_project/ ├── CMakeLists.txt ├── src │   └── demo_functions.f90 └── tests └── test_functions.f90

the functions which we would like to test are contained within the project src folder. When building tests it is important that you give this location, or the name of a compiled library to FortUTF using either the variable SRC_FILES or SRC_LIBRARY, the contents of the CMakeLists.txt shows this in practice, and point it to the location of our tests using the FORTUTF_PROJECT_TEST_DIR variable. In addition to include a directory containing module (.mod) files required to build the library being tested set the variable FORTUTF_PROJECT_MOD_DIR to this location.

```cmake CMAKEMINIMUMREQUIRED(VERSION 3.12)

PROJECT(DEMO_PROJ LANGUAGES Fortran)

MESSAGE(STATUS "[FortUTF Example Project Build]") MESSAGE(STATUS "\tProject Source Directory: ${PROJECT_ROOT}")

GETFILENAMECOMPONENT(FORTUTF_ROOT ../../ ABSOLUTE)

SET(FORTUTFPROJECTTESTDIR ${CMAKECURRENTSOURCEDIR}/tests) FILE(GLOB SRCFILES ${CMAKECURRENTSOURCEDIR}/src/*.f90)

INCLUDE(${FORTUTFROOT}/cmake/fortutf.cmake) FortUTFFind_Tests() ```

by including the file cmake/fortutf.cmake from within this repository we have access to the FortUTF_Find_Tests macro. We can place as many scripts in our FORTUTF_PROJECT_TEST_DIR location. An example script for this project is:

```fortran MODULE TESTDEMOFUNCTIONS USE FORTUTF USE DEMO_FUNCTIONS

CONTAINS
SUBROUTINE TEST_DEMO_FUNC_1
    USE DEMO_FUNCTIONS, ONLY: DEMO_FUNC_1
    CALL TAG_TEST("TEST_DEMO_FUNC_1")
    CALL ASSERT_EQUAL(DEMO_FUNC_1(10), 95)
END SUBROUTINE
SUBROUTINE TEST_DEMO_FUNC_2
    USE DEMO_FUNCTIONS, ONLY: DEMO_FUNC_2
    CALL TAG_TEST("TEST_DEMO_FUNC_2")
    CALL ASSERT_EQUAL(DEMO_FUNC_2(11D0), 32D0)
END SUBROUTINE

END MODULE TESTDEMOFUNCTIONS ```

Firstly we must include the FORTUTF module in every test script, then in order for FortUFT to be able to provide labels to any failing tests we tag using the TAG_TEST subroutine (not providing a tag will name the test Test <N> where N is the test number). Finally we call a test subroutine, and that's it!

To build this example we would then just run cmake within the project directory:

bash cmake -H. -Bbuild cmake --build build

this will create a script run_tests.f90 in the build directory and compile it into a binary.

Running the Framework Unit Tests

Even a test framework needs tests! FortUTF uses its own style of running to test all the assertions are behaving properly, to run the tests build them by running cmake with the option:

bash cmake -H. -Bbuild -DBUILD_TESTS=ON cmake --build build

the compiled binary is always named <PROJECT_NAME>_Tests and is run to execute the tests:

bash ./build/FortUTF_Tests

Optionally you can specify tests to run by the tagged name:

bash ./build/FortUTF_Tests TEST_FAIL_EQUAL_CHAR TEST_EQUAL_CHAR

Troubleshooting

If you experience any problems:

  • Try deleting the build directory and starting again.
  • Try putting the test subroutines into a module

Owner

  • Name: Kristian Zarębski
  • Login: artemis-beta
  • Kind: user

Citation (CITATION.cff)

# This CITATION.cff file was generated with cffinit.
# Visit https://bit.ly/cffinit to generate yours today!

cff-version: 1.2.0
title: FortUTF
message: >-
  If you use this software, please cite it using the
  metadata from this file.
type: software
authors:
  - given-names: Kristian
    family-names: Zarebski
    orcid: 'https://orcid.org/0000-0002-6773-1049'
  - given-names: Yen-Chen
    family-names: Chen
  - given-names: Victor
    family-names: Azizi
repository-code: 'https://github.com/artemis-beta/FortUTF'
url: 'https://artemis-beta.github.io/FortUTF/'
abstract: A purely FORTRANic framework for testing FORTRAN code
keywords:
  - fortran
  - test framework
  - unit test
  - software testing
license: AGPL-3.0-or-later
commit: 8486192b6f0aced7aaf78f6f04ce6e1438743bcb
version: 0.2.0-alpha
date-released: '2023-12-29'

GitHub Events

Total
  • Issues event: 1
  • Watch event: 1
  • Push event: 7
Last Year
  • Issues event: 1
  • Watch event: 1
  • Push event: 7

Committers

Last synced: about 2 years ago

All Time
  • Total Commits: 134
  • Total Committers: 5
  • Avg Commits per committer: 26.8
  • Development Distribution Score (DDS): 0.172
Past Year
  • Commits: 33
  • Committers: 3
  • Avg Commits per committer: 11.0
  • Development Distribution Score (DDS): 0.424
Top Committers
Name Email Commits
Kristian Zarebski k****2@g****m 111
Yen-Chen Chen y****4@g****m 19
Yen-Chen Chen y****n@k****u 2
Kristian Zarebski k****i@u****k 1
Victor Azizi v****r@l****u 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 12 months ago

All Time
  • Total issues: 10
  • Total pull requests: 14
  • Average time to close issues: 4 months
  • Average time to close pull requests: 2 days
  • Total issue authors: 3
  • Total pull request authors: 3
  • Average comments per issue: 1.6
  • Average comments per pull request: 0.93
  • Merged pull requests: 14
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 1
  • Pull requests: 2
  • Average time to close issues: 4 months
  • Average time to close pull requests: 11 days
  • Issue authors: 1
  • Pull request authors: 1
  • Average comments per issue: 1.0
  • Average comments per pull request: 2.0
  • Merged pull requests: 2
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • artemis-beta (7)
  • hemangh (2)
  • yanjen (1)
Pull Request Authors
  • yanjen (10)
  • artemis-beta (4)
  • v1kko (1)
Top Labels
Issue Labels
enhancement (3) bug (2) documentation (1)
Pull Request Labels
bug (1)

Dependencies

.github/workflows/futs_intel.yml actions
  • actions/checkout v3 composite
  • fortran-lang/setup-fortran v1 composite
  • jwlawson/actions-setup-cmake v1.14 composite
.github/workflows/futs.yml actions
  • actions/checkout v3 composite
  • codecov/codecov-action v3 composite
  • jwlawson/actions-setup-cmake v1.14 composite
.github/workflows/futs_mac.yml actions
  • actions/checkout v3 composite
  • jwlawson/actions-setup-cmake v1.14 composite
.github/workflows/futs_windows.yml actions
  • actions/checkout v3 composite
  • jwlawson/actions-setup-cmake v1.14 composite