-
Notifications
You must be signed in to change notification settings - Fork 45
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
Teach TRIBITS_ADD_ADVANCED_TEST()
new TEST_<IDX>
block type COPY_FILES_TO_TEST_DIR
#228
Comments
We need this for the TriBITS SPARC prototype build system ASAP (ATDV-84) so I will get working on this right now. Can you please review the spec for this in the above "Description" field and see if you see anything off? And once I have an initial implementation in a branch complete, can you please do a quick review on the PR branch? |
Overall this looks good to me. One question, will you be able to "configure" files that you copy like in CONFIGURE_FILE(...)? |
I don't think we can directly support that since Does that make sense? |
This is to get ready to do another refactoring in order to create some helper functions and clean the code up so that I can add add the code for COPY_FILES_TO_TEST_DIR.
This is to get ready to do another refactoring in order to create some helper functions and clean the code up so that I can add add the code for COPY_FILES_TO_TEST_DIR.
The full implementation is basically there now in the branch: As long as all of the files copy correctly, everything is fine (and I am already using this with the SPARC TriBITS prototype build system). The problem is what happens when a file does not copy (implemented with
And there is no way to control the error handling. It would be nice if the script could continue and and fail gracefully. So what to do? One idea is to handle the file copy using I think initially, we should just implement the single call to @fryeguy52, what do you think about this? |
Yes I agree that a single call seems better and we can deal with excessively long command-lines if that proves to be a problem later |
This is needed to allow TribitsAddAdvancedTest.cmake to be used in non-TriBITS project by just setting soem vars and including the file TribitsAddAdvancedTest.cmake.
As part of this commit, I also added the beginnings of a nested testing system for TRIBITS_ADD_ADVANCED_TEST(). Now I can use TAAT() to test the behvaior of TAAT() and now I test things that I could never directly test before.
I have a very strong test that ensures that a dest dir creation failure is handled gracefully.
FYI: The tip of the branch: now has a very robust implementation for failings in creating the dest dir and copying files and I added very strong (nested) testing to ensure the correct behavior. I feel very good about this implementation. Now I just need to add a check for zero or one SOURCE_DIR and DEST_DIR arguments and write the documentation ... |
Okay, so that is a bummer, but older versions of CMake (i.e. 2.8.11) do not support Therefore, to support CMake 2.8.11, we will have to change this to run This is another example of the problems we have with having to support older versions of CMake :-( |
…228) Wtih CMake 2.8.11 at least, you can't copy a set of files all together. You can only copy them one at a time. Therefore, we have to go with the single file copy appraoch. NOTE: The Travis CI server caught this since it runs with CMake 2.8.11.
#228) CMake 2.8.11 prints "Error making directory ..." while newer CMake prints "Error creating directory ..." so the needed regex change :-(
…#228) I added good unit tests that ensure that the correct number of arguments are passed into the arguments for the COPY_FILES_TO_TEST_DIR block.
Build/Test Cases Summary Enabled Packages: Enabled all Packages 0) MPI_DEBUG => passed: passed=260,notpassed=0 (0.70 min) 1) SERIAL_RELEASE => passed: passed=260,notpassed=0 (0.57 min) 2) MPI_DEBUG_CMAKE-3.6.2 => passed: passed=281,notpassed=0 (0.70 min) 3) SERIAL_RELEASE_CMAKE-3.6.2 => passed: passed=281,notpassed=0 (0.78 min) Other local commits for this build/test group: 76d548d, d86568e
This is needed to allow TribitsAddAdvancedTest.cmake to be used in non-TriBITS project by just setting soem vars and including the file TribitsAddAdvancedTest.cmake.
This new feature makes it easy to copy a bunch of files to a newly created TRIBITS_ADD_ADVANCED_TEST() working directory. As part of this, I refactored the DriveAdvancedTest.cmake code to clean it up and make it (hopefully) easier to understand. A major part of this is that I added a new way to test TAAT() by running TAAT() in a nested CMake project so that TAAT() can actually check that TAAT() is printing the right things and behaving as it should. This will be very useful when more refactorings and performed and new feature are added to TAAT().
…riBITSPub#228) This was a use case that I forgot to test and I accidentally hard-coded the default dest dir to be the test name dir.
@bartlettroscoe, any update on this issue? Perhaps a tentative timeframe? I'm in the midst of refactoring all of Charon's |
This has been done for a whike |
Could you give it a try and see how it works for you? |
Looks like it worked for one test. Let me try switching over the rest and see how it goes. |
Apparently I spoke too soon—should've done a clean build. Originally I had a INCLUDE(TribitsCopyFilesToBinaryDir)
INCLUDE(TribitsAddAdvancedTest)
TRIBITS_COPY_FILES_TO_BINARY_DIR(test_name_dir
SOURCE_FILES fileA fileB fileC
EXEDEPS exeName
NOEXEPREFIX
)
TRIBITS_ADD_ADVANCED_TEST(
test_name
TEST_0 EXEC exeName NOEXEPREFIX DIRECTORY /path/to/where/exeName/lives
ARGS --i=fileA
PASS_REGULAR_EXPRESSION "Run completed."
) I switched that to INCLUDE(TribitsAddAdvancedTest)
TRIBITS_ADD_ADVANCED_TEST(
test_name
TEST_0 COPY_FILES_TO_TEST_DIR fileA fileB fileC
TEST_1 EXEC exeName NOEXEPREFIX DIRECTORY /path/to/where/exeName/lives
ARGS --i=fileA
PASS_REGULAR_EXPRESSION "Run completed."
) Now when I run I see Note that the example above only shows a single test in the |
@jmgate, I may have missed this use case when adding the automated tests for this new feature. Note that all of the usages of this have used the (very useful) feature to create a new test subdirectory using the |
…#228) I added this test to make sure that the files are copied correctly with TRIBITS_ADD_ADVANCED_TEST() with the COPY_FILES_TO_TEST_DIR when there is no OVERALL_WORKING_DIRECTORY and there is an implicit SOURCE_DIR and DEST_DIR. This was a use case that was suspected of having a problem.
Thanks @bartlettroscoe— |
Note that I added a specific test that should cover the use case were described in this issue with But really most tests should use Sorry for the trouble this caused. |
No worries @bartlettroscoe. I've converted all of Charon's |
Should address use case mentioned in TriBITSPub/TriBITS#228. Build/Test Cases Summary Enabled Packages: Disabled Packages: PyTrilinos,Claps,TriKota Enabled all Packages 0) MPI_RELEASE_DEBUG_SHARED_PT => passed: passed=2542,notpassed=0 (101.95 min) Other local commits for this build/test group: 5c01d87, 09d5037
Summary: Teach
TRIBITS_ADD_ADVANCED_TEST()
newTEST_<IDX>
block typeCOPY_FILES_TO_TEST_DIR
CC: @fryeguy52
Description:
A very common idiom with the usage of
TRIBITS_ADD_ADVANCED_TEST()
is to copy files from the source tree to the test directory when a test runs. That has several advantages:CONFIGURE_FILE( ... COPYONLY)
or build again with TRIBITS_COPY_FILES_TO_BINARY_DIR() in order to copy files).Because of these advantages, projects like CASL VERA that use TriBITS almost always copy the files needed to run the test inside of the call to TRIBITS_ADD_ADVANCED_TEST() itself. That is not too hard to do using various commands like
cmake -E copy <from> <to>
but that is tedious to write the input blocks for a bunch of files to copy.Therefore, this Story is to add a new type of
TRIBITS_ADD_ADVANCED_TEST()
TEST_<IDX>
block calledCOPY_FILES_TO_TEST_DIR
(in addition toCMND
andEXEC
blocks) to copy files in bulk, with the structure:If
SOURCE_DIR <srcBaseDir>
is omitted, then<srcBaseDir>
is assumed to be${CMAKE_CURRENT_SOURCE_DIR}
. IfSOURCE_DIR <srcBaseDir>
is provided and<srcBaseDir>
is a relative path, then it is assumed to be relative to${CMAKE_CURRENT_SOURCE_DIR}
. If<srcBaseDir>
is an absolute path, then that path is used without question.If
DEST_DIR <destBaseDir>
is omitted, then<destBaseDir>
is assumed to be the current directory the binary where the test is runnin (usually${CMAKE_CURRENT_BINARY_DIR}/<fullTestName>
). IfDEST_DIR <destBaseDir>
is provided, and<destBaseDir>
is a relative path, then it is assumed to be relative to the directory the test is running in. (If there is a subdir path given, then that directory structure will be created under the binary test directory). If<destBaseDir>
is a absolute path, then that path is used without question. (However, it is not recommended to copy files into a directory that is not under the binary test directory as that removes some of the advantages of copying test files to the test directory inside of a test invocation in the first place).While this looks to be a simple feature to add, it has to involve the following:
TRIBITS_ADD_ADVANCED_TEST()
.Implementation Ideas:
The simplest way to implement this is likely to just implement the copy directly inside of the file
DriveAdvancedTest.cmake
using the commandCONFIGURE_FILE(<sourceBaseDir>/<filei> <destBaseDir>/<filei> COPYONLY)
. That could print a summary like:And it would show the file copy lines in real time and if timing was turned on, it would show timing for copying all of the files in bulk.
The greatest amount of work will be testing this. There is also the chance of breaking backward compatibility. That is, if someone was already using
COPY_FILES_TO_TEST_DIR
inside of some TRIBITS_ADD_ADVANCED_TEST() call, then this will break that. But that seems very unlikely.The text was updated successfully, but these errors were encountered: