# Unit Testing Frameworks for Fortran

**URL:** <https://fortran-lang.discourse.group/t/unit-testing-frameworks-for-fortran/6944>\
**Category:** Poll\
**Created:** [December 7, 2023, 4:59am UTC](https://fortran-lang.discourse.group/t/unit-testing-frameworks-for-fortran/6944 "2023-12-07T04:59:38Z")\
**Posts on this page:** 4\
**Page:** 2

<div class="post-metadata">

**Author:** ![ivanpribec](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/ivanpribec/32/3290_2.png) [@ivanpribec](https://fortran-lang.discourse.group/u/ivanpribec)\
**Post date:** [December 10, 2023, 9:17pm UTC](https://fortran-lang.discourse.group/t/unit-testing-frameworks-for-fortran/6944/21 "2023-12-10T21:17:04Z")

</div>

> [@jeff.irwin](#):
>
> I found that gfortran has an `isatty` function that you can use directly without the C binding.

Intel Fortran also has it: [ISATTY](https://www.intel.com/content/www/us/en/docs/fortran-compiler/developer-guide-reference/2024-0/isatty.html)

You have to watch out, because it’s available both as a non-standard built-in function that returns an integer, or as a function returning a logical value from the `ifport` module:

```fortran
use iso_fortran_env, only: output_unit, error_unit, input_unit
use ifport, only: ifport_isatty => isatty

print *, "Is input unit a tty?", isatty(input_unit) ! integer
print *, "Is output unit a tty?", ifport_isatty(output_unit) ! logical
print *, "Is error unit a tty?", ifport_isatty(error_unit) ! logical
end

```

I’m glad this question surfaced, as just a few days ago I read the following point in the [Command-Line Interface Guidelines](https://clig.dev/#help), unsure how to do this in Fortran:

> **If your command is expecting to have something piped to it and `stdin` is an interactive terminal, display help immediately and quit.** This means it doesn’t just hang, like `cat` . Alternatively, you could print a log message to `stderr`.

Using the program above shows the difference:

```txt
$ ifort -warn all tty.f90 # warnings omitted
$ ./a.out < tty.f90 2>error.txt
 Is input unit a tty? 0
 Is output unit a tty? T
 Is error unit a tty? F
$ ./a.out                      
 Is input unit a tty? 1
 Is output unit a tty? T
 Is error unit a tty? T

```

---

<div class="post-metadata">

**Author:** ![Carltoffel](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/carltoffel/32/1680_2.png) [@Carltoffel](https://fortran-lang.discourse.group/u/Carltoffel)\
**Post date:** [December 11, 2023, 6:15am UTC](https://fortran-lang.discourse.group/t/unit-testing-frameworks-for-fortran/6944/22 "2023-12-11T06:15:11Z")

</div>

> [@danielc](#):
>
> I think you forgot to copy the minimal example. I’m curious to see it.

I updated my reply 🙂

---

<div class="post-metadata">

**Author:** ![soraoka](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@soraoka](https://fortran-lang.discourse.group/u/soraoka)\
**Post date:** [March 20, 2024, 5:29pm UTC](https://fortran-lang.discourse.group/t/unit-testing-frameworks-for-fortran/6944/24 "2024-03-20T17:29:10Z")

</div>

I’m also looking for a Unit Testing framework. I created a list of 27 frameworks. I ordered them by the date they were updated. And “veggies” came up #1. Seemed pretty good, until I saw that it required fpm. I work in a Government closed network where I can’t run anything that goes out to the internet. In fact many of those 27 frameworks use fpm. I’m currently looking at ObjexxFTK.

---

<div class="post-metadata">

**Author:** ![hkvzjal](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/hkvzjal/32/3055_2.png) [@hkvzjal](https://fortran-lang.discourse.group/u/hkvzjal)\
**Post date:** [March 20, 2024, 6:08pm UTC](https://fortran-lang.discourse.group/t/unit-testing-frameworks-for-fortran/6944/25 "2024-03-20T18:08:06Z")

</div>

It seems to me that there are two misconceptions here, I’ll let @everythingfunctional and @FedericoPerini correct me if I’m wrong:

1. Veggies, is **compatible** with `fpm` for building it and fetching online its dependencies which are

```toml
iso_varying_string = { git = "https://gitlab.com/everythingfunctional/iso_varying_string.git", tag = "v3.0.3" }
strff = { git = "https://gitlab.com/everythingfunctional/strff.git", tag = "v3.1.1" }

```

But nothing is stopping you from downloading them individually and then compiling with another build tool like CMake for instance … or with `fpm` after changing in the fpm.toml file the location of the dependencies to a local folder instead of a git server online. For instance:

```toml
iso_varying_string = { path = "some/local/path/iso_varying_string" }
strff = { path = "some/local/path/strff" }

```

(The path should point to the folder containing the fpm.toml of the given library)

1. `fpm` does not upload anything to the internet unless you want to make your project part of the Fortran registry, which in itself is still a work in progress and by default no project is uploaded to it (AFAIK).

[Previous page](https://fortran-lang.discourse.group/t/unit-testing-frameworks-for-fortran/6944.md?page=1)
