Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement test/executable specific dependencies #85

Conversation

everythingfunctional
Copy link
Member

At this point it's kind of a terrible, ugly, hacked together prototype, but it works. And allows for "semi"-circular dependencies. If one of your test or executable dependencies depends on your library, it will still work.

 - with the possibility of them being "circular", meaning if
   one of them depends on the current library, it will still
   work
@everythingfunctional
Copy link
Member Author

My use case for this is that vegetables depends on both iso_varying_string and strff, but I want to be able to use vegetables to test them. This way that will work.

I still need to try to migrate these to using fpm to be sure that it will work, but I'll try that over the next day or two. The test I added suggests it will.

@certik certik changed the title Impelement test/executable specific dependencies Implement test/executable specific dependencies May 30, 2020
@certik
Copy link
Member

certik commented May 30, 2020

Yes, we need this feature. However, let's follow the Cargo's syntax? Or do you have reasons why that's not a good idea in this case?

https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#development-dependencies

It has [dependencies] for just building the package, and additional [dev-dependencies] for building tests / benchmarks etc.

Currently you have:

[[test]]
  name = "test"
  source-dir = "tests"
  main = "main.f90"
  [test.dependencies]
    circular_test = { path = "../circular_test" }

Let's instead do:

[dev-dependencies]
    circular_test = { path = "../circular_test" }

[[test]]
  name = "test"
  source-dir = "tests"
  main = "main.f90"

And finally fpm should be clever enough to figure out the tests from the layout only (eventually), so it would become just:

[dev-dependencies]
    circular_test = { path = "../circular_test" }

In Cargo you can specify also dependencies for a particular target only. But it seems this dev-dependencies would cover 90% of use cases, including yours (I think).

@certik
Copy link
Member

certik commented May 30, 2020

My other comment is that instead of adding tests in the root directory as examples, let's move them in the tests directory?

@everythingfunctional
Copy link
Member Author

I'm not opposed to also having [dev-dependencies], but my question would be, are those used for the executables too? Or would we want to have [test-dependencies] and [exe-dependencies]?

I can move the tests into the tests directory. That's no problem.

@everythingfunctional
Copy link
Member Author

I was able to try this out converting a few of my libraries to using fpm, and it works great. This will make it possible for me to convert (almost) all of my packages to fpm.

@certik
Copy link
Member

certik commented May 31, 2020

I am not sure about the executables --- I would expect that dev-dependecies only work for tests, benchmarks etc.

In your use case, you have to have special dependencies for executables?

@everythingfunctional
Copy link
Member Author

I don't personally have a project with special dependencies for an executable, but I could envision one. Somebody develops and tool, and there's a library that goes along with it, but the executable has dependencies that user's of the library don't necessarily need. The use case is probably rare enough, and covered by the executable/test specific dependencies I've already implemented that having dev-dependencies only for tests is probably fine. I'll get that implemented.

@certik
Copy link
Member

certik commented May 31, 2020 via email

Copy link
Member

@certik certik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this looks good to me to merge.

The [dev-dependencies] is working, tests are added, so we can improve upon this with subsequent PRs.

Thank you Brad! I think we are getting very close to make fpm usable in real projects.

I'll try this myself on my projects soon.

@milancurcic
Copy link
Member

Sorry, I don't have time to review this but please go forward with it and I will play with it at a later time.

Copy link
Member

@milancurcic milancurcic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed the examples and the addition to the guide, all looks good to me.

@everythingfunctional everythingfunctional deleted the TestOnlyDependencies branch June 1, 2020 22:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants