-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Please add simple example of what you mean in "Why do my tests take so long to compile? page". #632
Comments
Compile all test files, including file(GLOB tests_srcs tests/*.cc) # let's say your test_*.cc files are under "tests" folder
add_executable(run ${tests_srcs}) # and the test executable is "run"
target_link_libraries(run your_library_target)
add_test(testall tests/run) # and the executable also lies under "tests" folder |
Or, see my gist CATCH - Small complete multi-file example. |
I think it would be instructional to include simple compilation commands with examples, like Compile file with main once:
Subsequently use above object file:
|
@martinmoene How about changing the last paragraph to this?
|
The text nicely explains it. Adding a simple commandline (in some form) may make it easier to quickly see the point. |
My suggestion comes from how we scan-read (web) pages to find the information we need. Just like titles, a command line stands off from the main text and draws our attention helping find what we need and determine if we need/want to read the nearby text any further. In general, I think it's helping a reader to present examples with compilation command and output. Doing so obviates the need for the reader to guess what's not there (even if that may seem obvious for the writer) and it reassures the reader they are understanding the matter at hand. |
Ok, I expanded the section a bit more yet. |
@horenmar Now even better that I imagined 😄 |
That was not supposed to be there! |
You say to have a single file with #define CATCH_CONFIG_MAIN and #include "catch.hpp", but I don't understand where the tests would be. Are you saying that you would have foo.cpp foo_test.cpp and catch.cpp (with the two lines) all compiled together. Then you might have bar.cpp so you would compile bar.cpp, bar_test.cpp and catch.cpp together for testing bar code? Then if you had foobar.cpp (that depends on foo and bar) you would compile foo.cpp, foo_test.cpp, bar.cpp, bar_test.cpp, foobar.cpp, foobar_test.cpp, and catch.cpp all together?
You do a great job of explaining why it is slow but don't explain very well what a solution would look like other than saying a single cpp file with the two lines. I think the simple example (of a real world situation) would make everything clear.
Thanks,
SLDR
(Stephen L. De Rudder)
URL: https://github.com/philsquared/Catch/blob/master/docs/slow-compiles.md
PS: Call it best practices if you don't want everyone just blindly doing it this way, but for people with large projects that don't want to blaze their own path or reinvent the wheel; an example for many c++ modules with dependencies would get them off the ground quick.
PSS: My $0.02 worth.
The text was updated successfully, but these errors were encountered: