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

WIP: automatic discovery and build of tests and examples #73

Closed
wants to merge 16 commits into from

Conversation

GPMueller
Copy link
Contributor

@GPMueller GPMueller commented Oct 7, 2018

Not yet ready for merging

The goal of this PR is to bring this feature far enough that at least a few boost libraries can be built including tests and examples and that there be some reasonable way of executing the tests.
GLFW will be another case to try this on.

  • implement folder discovery
  • ability to build tests
  • handle dependencies of tests
  • ability to build examples
  • (de-)activation of building test/example executables via CLI flags, correctly decide if there are any tests to be built
  • distinguish between immediate and recursive discovery/build of tests and examples
  • better dependency graph dotfiles (the tests and examples would clutter the main graph, they should be shown separately)
  • documentation
  • unit tests

- if a test folder is found, clang-build will try to build an executable from the sources
- a "tests" subcategory of the target configuration can be used to control sources, flags and dependencies
- the command line flags are not yet connected
The default is true.
If set to false, one executable is created per source file.
@GPMueller GPMueller added enhancement New feature or request discussion Something that might end up being labled enhancement or wontfix labels Oct 7, 2018
With this, as intended, the --tests flag is needed to build tests.
@codecov
Copy link

codecov bot commented Oct 8, 2018

Codecov Report

Merging #73 into master will decrease coverage by 0.63%.
The diff coverage is 81.04%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #73      +/-   ##
==========================================
- Coverage   81.07%   80.43%   -0.64%     
==========================================
  Files          12       12              
  Lines         983     1094     +111     
==========================================
+ Hits          797      880      +83     
- Misses        186      214      +28
Impacted Files Coverage Δ
clang_build/clang_build.py 71.28% <100%> (+2.63%) ⬆️
clang_build/io_tools.py 100% <100%> (ø) ⬆️
clang_build/dependency_tools.py 70.45% <100%> (+6.56%) ⬆️
clang_build/project.py 66.11% <29.03%> (-5.72%) ⬇️
clang_build/target.py 89.96% <92.13%> (-0.12%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 88f833d...cfd0ca1. Read the comment docs.

Todo: warnings, if tests dependencies cannot be found.
Also added a todo comment that we need to improve detection of circular dependencies.
@NOhs
Copy link
Collaborator

NOhs commented Aug 14, 2019

Can't we already have tests, if we group them in a test folder? Aren't tests basically normal targets?

@GPMueller GPMueller changed the title Tests and Examples: automatic discovery and build (WIP) WIP: automatic discovery and build of tests and examples Aug 15, 2019
@GPMueller
Copy link
Contributor Author

GPMueller commented Aug 15, 2019

In #72 I describe how I would expect the feature to work. The point would be to not have to manually specify tests and examples targets. For small projects this could eliminate the need to have a configuration file.
Further, most tests and examples have almost identical content, as they should test the same library, and this can become especially annoying when one wants to define many test executables.

Also, this feature would allow building (maybe later also running?) tests recursively for all targets and their dependencies using the --test-recursive flag (and analogous for examples).

One issue that I ran into is the linking of shared library targets, since they are not placed into the test or example binary directories. So executing the tests and examples only works out of the box for static libraries (see also #25).

The dependency graph now includes tests and examples and their dependencies.
This fixes problems with include folders etc.
Also added `rankdir="BT"` global attribute to dependency graph.
@GPMueller GPMueller force-pushed the feature-tests branch 2 times, most recently from ebbfe4a to 62546c3 Compare August 17, 2019 21:23
@GPMueller GPMueller requested a review from NOhs August 18, 2019 10:27
This example makes use of the automatic tests and exmaples feature.
- fixed relative paths of sources for tests and examples
- fixed a bug with Windows paths being parsed from the depfile
- fixed Project.get_targets, which now correctly returns also the test and example targets
This is for targets and examples.
@GPMueller
Copy link
Contributor Author

Closing this PR.

The implementation on this PR is unsuitable for proper usage. The tests/examples might not only depend on the given target itself, but also on other libraries, potentially from a different subproject. This means that tests/examples dependencies need to be resolved after the creation of the full dependency graph.

The build stage improvements described in issue #64 should be implemented first, and a new version of this feature should be implemented.

@GPMueller GPMueller closed this Sep 16, 2019
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 enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Automatically discover and enable building of tests and examples
2 participants