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

Automatically discover and enable building of tests and examples #72

Open
GPMueller opened this issue Oct 7, 2018 · 2 comments
Open
Labels
discussion Something that might end up being labled enhancement or wontfix

Comments

@GPMueller
Copy link
Contributor

GPMueller commented Oct 7, 2018

Depends on #64.

Questions which need to be answered in order to implement this:

  • how to set include directories and flags for tests and examples
  • should one be able / how to switch between one test per source file and one executable for all the sources
  • what should be the build folder structure
  • can / should include directories and flags be set per example
  • can / should we enable more complex examples, where additional sources are compiled into an example
  • should there be a command build tests, e.g. clang-build tests and/or to run tests, e.g. clang-build runtests
  • should the test and example executables appear in the dependency graph, or should separate dependency graphs be created for them?

My suggestions for what we should encourage:

  • tests should be inside a tests folder and examples in an examples folder
  • sources inside the tests folder should be compiled into a single executable
  • sources in the examples folder should be compiled into one example each

Example config:

[mylib]
    target_type = "static library"
    sources = ["src/*.cpp"]

[mylib.tests]
    sources = ["tests/*.cpp"]

[mylib.examples]
    include_directories = ["deps"]
    sources = ["examples/*.cpp", "deps/something.cpp"] # does something like this make sense?
    [mylib.examples.flags]
        compile = ["-Wno-unused-parameter"]

Tests in the boost libraries are messier than I expected... They have a lot of files which are meant to not compile and therefore have to be excluded form the test builds. Also, some tests require additional flags, which the library does not.
I'm not sure yet, but it seems some tests also have additional dependencies on other boost libraries...

Therefore, a tests section in the target config seems necessary to me. It should at least contain sources or sources exclude patterns and flags.

@GPMueller GPMueller added the discussion Something that might end up being labled enhancement or wontfix label Oct 7, 2018
@thautwarm
Copy link
Contributor

I prefer to invoke clang-build multiple times with different configuration settings to deal with library, test, and examples...

It seems to be quite easy and, if we can made it this way, it'd be better if we keep clang-build simpler.

@GPMueller
Copy link
Contributor Author

When PR #108 is merged, a revised and improved implementation of this feature can be made and PR #102 closed. Due to the improved dependency resolution process, tests and examples will be able to automatically notice when a dependency is missing.

There still remains the question how to represent tests and examples in the dependency graph:

  • use Tests and Examples classes, derived from Target, which potentially have several output files?
  • create Executable targets for each test and example?

Note, in both cases, corresponding TargetDescriptions will be necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Something that might end up being labled enhancement or wontfix
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants