'Fortran fpm Run Tests on Module in Parent Directory
I have written a module in fortran that I want to test using fortran-fpm and vegetables.
My directory structure looks like this:
my_repo/
├─ foo/
│ ├─ bar/
│ │ ├─ my_module.f90
│ │ ├─ test/
│ │ │ ├─ main.f90
│ │ │ ├─ my_module_test.f90
├─ fpm.toml
When I run fpm test, I get this error:
<ERROR>*cmd_run*:targets error:Unable to find source for module dependency: "my_module" used by "foo/bar/test/my_module_test.f90"
STOP 1
If I instead move my_module.f90 into the test directory, all the tests run fine. How do I point my_module_test.f90 to my_module.f90 without having my source code in the test directory?
I have tried:
- Including:
[test-dependencies]
my_module = { path = "foo/bar/my_module.f90" }
in my fpm.toml file at the top of my repo as suggested in the documentation. It then prompts me to put another fpm.toml file at foo/bar/. When I do that, it still gives me the same error.
- Using putting
file: "foo/bar/my_module.f90at the top ofmy_module_test.f90. As suggested here.
EDIT: Note that my fpm.toml file looks like this:
name = "My_Project"
author = "NolantheNerd"
[install]
library = true
[library]
source-dir = "foo/bar"
include-dir = "foo/bar"
[build]
external-modules = "foo/bar"
link = "foo/bar/my_module.f90"
[dev-dependencies]
vegetables = { git = "https://gitlab.com/everythingfunctional/vegetables.git", tag = "v7.2.2" }
[[test]]
name = "TestsForMyModule"
source-dir = "foo/bar/test"
main = "main.f90"
link = "foo/bar/my_module.f90"
Solution 1:[1]
Many thanks to everythingfunctional, the creator of vegetables for his solution:
Your build section is incorrect, and actually unnecessary in your case. Try removing it and let us know how it goes.
Edit: just noticed as well that the link entry in your test section is incorrect and unnecessary as well.
See the thread here.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | NolantheNerd |
