-
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
Add some error checking and reporting for common TriBITS project developer and user mistakes #200
Comments
@fryeguy52, I think this is a natural story to go along with setting up a tutorial for TriBITS in #190. |
Ready to start adding failures!
@fryeguy52 and I pair programmed the starter to this in: @fryeguy52, please checkout out this branch in your local git repo on my machine crf450 and continue one. Let me know if you have questions. |
This adds a new dummy testing TriBITS package PkgWithUserErrors that will be used to test for user errors. In following commits, we will optionally break this various ways!
Build/Test Cases Summary Enabled Packages: Enabled all Packages 0) MPI_DEBUG => passed: passed=251,notpassed=0 (0.74 min) 1) SERIAL_RELEASE => passed: passed=251,notpassed=0 (0.70 min) 2) MPI_DEBUG_CMAKE-3.6.2 => passed: passed=272,notpassed=0 (0.83 min) 3) SERIAL_RELEASE_CMAKE-3.6.2 => passed: passed=272,notpassed=0 (0.74 min) Other local commits for this build/test group: 8d7fb25, 4d988ab, cfb441b
I just merged the branch 'user-error-checking-200' that takes care of several of these checks (see above 'description' field). Note that there are still several types of checks mentioned above. |
…200) There is a new macro defined in TribitsGlobalMacros.cmake called "TRIBITS_PARSE_UNPARSED_ARGS" that checks to see if there are any unparsed arguments and throws an error if there are.
…200) There is a new macro defined in TribitsGlobalMacros.cmake called "TRIBITS_PARSE_UNPARSED_ARGS" that checks to see if there are any unparsed arguments and throws an error if there are. Build/Test Cases Summary Enabled Packages: Enabled all Packages 0) MPI_DEBUG => passed: passed=252,notpassed=0 (0.66 min) 1) SERIAL_RELEASE => passed: passed=252,notpassed=0 (0.61 min) 2) MPI_DEBUG_CMAKE-3.6.2 => passed: passed=273,notpassed=0 (0.62 min) 3) SERIAL_RELEASE_CMAKE-3.6.2 => passed: passed=273,notpassed=0 (0.67 min)
@fryguy52, I cherry-picked, tested, and pushed the commit 9c09636 which was pushed as the commit 3559d6b. I then deleted the user-error-checking-200 branch:
For any future work on this story, we should create follow-on topic branches like |
Wow, this argument must have never actually worked. Very bad. This fixes usage with Trilinos. We really need a better automated test for this but the only usage was related to SIERRA (which I don't think is being used anymore).
#200) The new default will allow an existing TriBITS project to keep working but just print out of warnings for unparsed otherwise ignored argumetns. But this var can be set to error out as well (see developers guide documentation). This default had to be changed or it would be a nighmare to upgrade existing projects. For example, it took a while to upgrade Trilinos and we should expect many mistakes like this in other TirBITS projects.
Build/Test Cases Summary Enabled Packages: Enabled all Packages 0) MPI_DEBUG => passed: passed=252,notpassed=0 (0.76 min) 1) SERIAL_RELEASE => passed: passed=252,notpassed=0 (0.68 min) 2) MPI_DEBUG_CMAKE-3.6.2 => passed: passed=273,notpassed=0 (0.65 min) 3) SERIAL_RELEASE_CMAKE-3.6.2 => passed: passed=273,notpassed=0 (0.73 min) Other local commits for this build/test group: 822a64a, 7e64c76
…#200) Now that many TriBITS functions check for unparsed arguments, mistakes like this are caught.
After fixing fixing an misspelled TriBITS argument, this was again populating the SIERRA/ directory with configured headers. The current SIERRA Trilinos integration process does not use this anymore so there is no reason to keep populating these headers. Therefore, this has been commented out (and the misspelling was fixed). This was triggered by change in TriBITSPub/TriBITS#200 for catching unparsed arguments.
…#200) The change in TriBITS to flag unparsed otherwise ignored arguments showed that these add on values were being ignored (and indeed, they served no purpose).
…ITS#200) The change in TriBITS to flag unparsed otherwise ignored arguments showed that these add on values were being ignored (and indeed, they served no purpose).
…BITS#200) The change in TriBITS to flag unparsed otherwise ignored arguments showed that these add on values were being ignored (and indeed, they served no purpose).
…bpackages (#200) The SCOREC packages was generating strange configure errors when it was trying to call commands for a package with subpackages but did not have any subpackages. The error message was terrible in this case. I added a new check and new test case to produce a good error message. Hopefully that would have made it easier to fix the error in the SCOREC package. I also improved the error message to mention that you can call TRIBITS_PACKAGE_DECL() and TRIBITS_PACKAGE_DEF() or TRIBITS_PACKAGE() before TRIBITS_PACKAGE_POSTPROCESS(). That hopefully is a little better error message? In any case, I think we need to go over these error messages a little more to make sure they provide the best info to the developer. Build/Test Cases Summary Enabled Packages: Enabled all Packages 0) MPI_DEBUG => passed: passed=263,notpassed=0 (0.72 min) 1) SERIAL_RELEASE => passed: passed=263,notpassed=0 (0.59 min) 2) MPI_DEBUG_CMAKE-3.6.2 => passed: passed=284,notpassed=0 (0.56 min) 3) SERIAL_RELEASE_CMAKE-3.6.2 => passed: passed=284,notpassed=0 (0.54 min)
@bartlettroscoe it looks like your commit fixed this. Do you need me to do anything? |
I think I fixed this use case. If we see other cases like this come up, we may need to dig in and try to improve the error checking and error messages. It turns out that in the case of SCOREC that it used to have subpackages then it was refactored to not have subpackages but the top-level SCOREC CMakeLists.txt file never got updated. It turns out that worked just fine. But the new checking did not allow that use case. I added a check to disallow that. But I still allowed one to call TRIBITS_PACKAGE_DECL() and TRIBIT_PACAKGE_DEF() instead of TRIBITS_PACKAGE() for packages with no subpackages. I am not sure if we should allow that or not but it seems okay to do that. |
* develop: (812 commits) MueLu: comment out mmayr research subdirectory Enable Tacho in Kokkos promotion configuration Shylu/Tacho - fix the unit test failure described in trilinos#1935 Tpetra: Fix spelling errors (see trilinos#1956) Intrepid2: implementing new design suggested by Kyungjoo to have work view of rank 1, instead of having a work view of rank 2 or 3. In this case we have to expose Fad dimension. Intrepid2: introduce new function get_dimension_scalar(view) that returns the dimension_scalar(view), for non pod view types (defined e.g. in Sacado) and returns 1 for pod types. HHG: 1D test code to figure out issues with parallelism MueLu tutorial: correct instructions in README file MueLu/HHG: setup row maps for each region MueLu/HHG: setup data structure to store all nodes in each region MueLu/HHG: read proc info from file MueLu/HHG: write region matrix information to file (using Matlab) MueLu/HHG: attempt to fix indices MueLu/HHG: First draft of regional splitting of matrices MueLu/HHG by Max: move creation of Xpetra::MatrixSplitting to driver MueLu/HHG by Max: move creation of RegionHandler to Test_xpetra.cpp Single versus double colon. Fixed FS example. ShyLU: Add missing TRIBITS_PACKAGE_DEF() calls (TriBITSPub/TriBITS#200) Enable ST code in ST extrab builds ...
* Improve error messages from new TriBITS usage checks (TriBITSPub/TriBITS#200). * Some new features for gitdist: - default-branch (TriBITSPub/TriBITS#235) - move-to-base-dir (TriBITSPub/TriBITS#212)
This will allow adding other modes.
…_REPORT_INVALID_TRIBITS_USAGE() (#200)
…issing call to TRIBITS_REPORT_INVALID_TRIBITS_USAGE() (#200)
… set default for dev mode (#200) This also sets ${PROJECT_NAME}_ENABLE_DEVELOPMENT_MODE_DEFAULT=ON if it is not set. This is what it should have always been from the beginning. Hopefully this will not break any existing TriBITS projects (but it is easy to fix by just setting the default in the <projectDir>/ProjectName.cmake file).
…T_TRIBITS_USAGE (#200) This will allow CASL VERA to set: SET(${PROJECT_NAME}_ASSERT_CORRECT_TRIBITS_USAGE_DEFAULT WARNING) so that it can upgrade TriBITS and then deal with the invalid usage warnings after that. This also sets ${PROJECT_NAME}_ENABLE_DEVELOPMENT_MODE_DEFAULT=ON by default if it is not set by the project. This is what it should have always been from the beginning. Hopefully this will not break any existing TriBITS projects (but it is easy to fix by just setting the default in the <projectDir>/ProjectName.cmake file).
…T_TRIBITS_USAGE (#200) This will allow CASL VERA to set: SET(${PROJECT_NAME}_ASSERT_CORRECT_TRIBITS_USAGE_DEFAULT WARNING) so that it can upgrade TriBITS and then deal with the invalid usage warnings after that. This also sets ${PROJECT_NAME}_ENABLE_DEVELOPMENT_MODE_DEFAULT=ON by default if it is not set by the project. This is what it should have always been from the beginning. Hopefully this will not break any existing TriBITS projects (but it is easy to fix by just setting the default in the <projectDir>/ProjectName.cmake file). Build/Test Cases Summary Enabled Packages: Enabled all Packages 0) MPI_DEBUG => passed: passed=357,notpassed=0 (1.54 min) 1) SERIAL_RELEASE => passed: passed=357,notpassed=0 (1.56 min) Other local commits for this build/test group: eda8438
FYI: I have descoped this story and added the remaining checks to the new story #339. Therefore, I will close this story as complete. |
…riBITSPub#274, TriBITSPub#200) As part of this, I also fixed how the error messages were formatted. Function and macro names should have () after them and I fixed other formatting problems.
…riBITSPub#274, TriBITSPub#200) As part of this, I also fixed how the error messages were formatted. Function and macro names should have () after them and I fixed other formatting problems.
…TriBITSPub#200) This eliminates a lot of dupication, reduces the number of lines of code, and removes a bunch of clutter from the functions tribits_add_test_directories() and tribits_add_example_directories(). Win, win, win. I noticed this while working on TriBITSPub#510.
…TriBITSPub#200) This eliminates a lot of dupication, reduces the number of lines of code, and removes a bunch of clutter from the functions tribits_add_test_directories() and tribits_add_example_directories(). Win, win, win. I noticed this while working on TriBITSPub#510.
That code just clutters up the main macros() and makes them hard to reason about and maintain.
That code just clutters up the main macros() and makes them hard to reason about and maintain.
That code just clutters up the main macros() and makes them hard to reason about and maintain.
…#200) The change in TriBITS to flag unparsed otherwise ignored arguments showed that these add on values were being ignored (and indeed, they served no purpose).
Next Action Status:
Added checks for usage of TRIBITS_PACKAGE(), TRIBITS_PACKAGE_POSTPROCESS(), etc. and some other things. Next: Need to add checks for TRIBITS_SUBPACKAGE(), TRIBITS_SUBPACKAGE_POSTPROCESS(), etc.
CC: @fryeguy52
Description:
The TriBITS framework can reduce some of the boiler plate raw CMake code that project developers need to write when setting up a CMake build and tests with CTest in their CMakeLists.txt files. However, history has shown that project developers and TriBITS project users made some common mistakes when using TriBITS. TriBITS already contains error checks and reporting for many types of common mistakes (e.g. misspelling the name of a TriBITS SE package, or trying to create a circular dependency) but there are many other types of mistakes that are not currently caught and reported very gracefully (e.g. not calling TRIBITS_PROJECT_POSTPROCESS() at the end of a packages's CMakeLists.txt file)
This Story is to add error checking and reporting (using
MESSAGE(FATAL_ERROR ...)
) for many common mistakes. An initial list of the mistakes that can be caught and gracefully reported are:Check that
TRIBITS_PACKAGE()
is called beforeTRIBITS_ADD_LIBRARY()
orTRIBITS_ADD_EXECUTABLE()
. [DONE]Check that
TRIBITS_PACKAGE_DECL()
,TRIBITS_PACKAGE_DEF()
,TRIBITS_PACKAGE_POSTPROCESS()
,TRIBITS_PROJECT()
and many other such user-facing macros and functions are called only once (i.e. per package for package-level functions and once per project for project-level functions). [DONE]Check that
TRIBITS_PACKAGE_POSTPROCESS()
is called before the end of the package's CMakeLists.txt file after all other commands likeTRIBITS_ADD_LIBRARY()
andTRIBITS_ADD_EXECUTABLE()
. [DONE]Check that all of the arguments to
TRIBITS_PROJECT_DEFINE_DEPENDENCIES()
match named arguments (e.g. look for non-emptyPARSE_UNPARSED_ARGUMENTS
after callingCMAKE_PARSE_ARGUMENTS(PREFIX ...)
and abort if found). [DONE]Add checks for all TriBITS functions and macros that use
CMAKE_PARSE_ARGUMENTS(PREFIX ...)
forPARSE_UNPARSED_ARGUMENTS
when they should not exist. [DONE]Add checks that
TRIBITS_SUBPACKAGE()
,TRIBITS_SUBPACKAGE_POSTPROCESS()
, etc. are called correctly [DONE]Check that TRIBITS_PACKAGE() is not called in the base CMakeLists.txt file for a package that has subpackages. Instead, they must call TRIBITS_PACKAGE_DECL() and TRIBITS_PACKAGE_DEF() (with TRIBITS_PROCESS_SUBPACKAGES() called in between). [DONE]
Check that missing a call to TRIBITS_PROCESS_SUBPACKAGES() is caught if one forgets to call it before TRIBITS_PACKAGE_DEF() is called. [DONE]
Check that if only TRIBITS_PACKAGE_DECL() is called in parent packages's CMakeList.txt file that TriBITS reports the user needs to call TRIBITS_PROCESS_SUBPACKAGES() next. [DONE]
Check that TRIBITS_PACKAGE_DEF() is called once and only once in a parent packages's CMakeLists.txt file. [DONE]
Check that a subpackages's CMakeLists.txt files do not call any of the commands TRIBITS_PACKAGE(), TRIBITS_PACKAGE_DECL(), TRIBITS_PACKAGE_DEF(), TRIBIITS_PROCESS_SUBPACKAGES(), TRIBITS_PACKAGE_POSTPROCESS(). [DONE]
Check that TRIBITS_ADD_TEST_DIRECTORIES() and TRIBITS_ADD_EXAMPLE_DIRECTORIES() are called between TRIBITS_SUBPROJECT() and TRIBITS_SUBPROJECT_POSTPROCESS() (and the same for a top-level packages). [DONE]
The above are just a few of the types of mistakes that TriBITS developers and users have made in the past and TriBITS does not catch and report very well. Some more thought and exploration will yield other missing checks. But this story does not have to involve finding and resolving all such errors.
What makes this story non-trivial is that we must set up automated testing to check that TriBITS can catch and report these mistakes. To do that, one could set up new testing dummy TriBITS package(s) that can be configured to make all of these mistakes and then add automated tests in the TriBITS test suite to make sure that TriBITS code catches the mistakes and prints the right error messages.
The text was updated successfully, but these errors were encountered: