diff --git a/CI/CMakeLists.txt b/CI/CMakeLists.txt index 4789ea988c6e7f253a339845e20e53e9e56b7924..bc8bebbe8b7b83984491644291b83e727e9e3ec5 100644 --- a/CI/CMakeLists.txt +++ b/CI/CMakeLists.txt @@ -1,3 +1,9 @@ + +# Declare the package's name to the build. This is necessary for it +# to show up nicely in the build results. +atlas_subdir( CI ) + +# Declare tests for the "package": add_test (NAME DomainMapTests COMMAND python -m test.test_domain_map WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) add_test (NAME WatchListTests COMMAND python -m test.test_watch_list WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) set_property (TEST DomainMapTests WatchListTests APPEND PROPERTY LABELS CI) diff --git a/CI/domain_map.py b/CI/domain_map.py index 338fcccd85c54d4cd935d526a50b93993d5d7244..d72c7b071f7a5df4d97fa66aea4ed6a758f3467c 100644 --- a/CI/domain_map.py +++ b/CI/domain_map.py @@ -4,7 +4,7 @@ DOMAIN_MAP = {} DOMAIN_MAP['Analysis'] = set(['^PhysicsAnalysis/']) -DOMAIN_MAP['Build'] = set(['^Build/','^Projects/']) +DOMAIN_MAP['Build'] = set(['^Build$','^Projects/']) DOMAIN_MAP['Calorimeter'] = set(['^Calorimeter/']) DOMAIN_MAP['CI'] = set(['^CI']) DOMAIN_MAP['Core'] = set(['^Control/']) diff --git a/CI/run_unit_tests_for_mr.py b/CI/run_unit_tests_for_mr.py index 7257d6f76fee6694b2bc192a57c50f0ee32f7262..030c6d584d588654a9bb4f918dfbabb3dbf30f0e 100644 --- a/CI/run_unit_tests_for_mr.py +++ b/CI/run_unit_tests_for_mr.py @@ -21,16 +21,30 @@ def run_unit_tests(args): logging.debug("changed files:\n" + print_collection(changed_files)) affected_packages = sorted(set([map_filename_to_package(f) for f in changed_files])) - # assemble ctest command - ctest_cmd = "ctest --output-on-failure " - for p in affected_packages: + # construct list of patterns for matching test labels + pattern_list = [] + for package_path in affected_packages: + # ignore empty package paths which would trigger all tests + # (empty package paths may appear due to failed mapping) + if not package_path: + continue + # label is package name and not full package path - ctest_cmd += "-L ^" + os.path.basename(p) + " " + pattern_list.append("^" + os.path.basename(package_path) + "$") + + # only run tests if we found some patterns for test labels + if pattern_list: + # assemble ctest command + ctest_cmd = "ctest --output-on-failure " + ctest_cmd += "-L \"" + "|".join(pattern_list) + "\"" - # execute - logging.debug("ctest command = '%s'" % ctest_cmd) - status = subprocess.call(ctest_cmd,shell=True) - return status + # execute + logging.debug("ctest command = '%s'" % ctest_cmd) + status = subprocess.call(ctest_cmd,shell=True) + return status + # no tests -> return success + else: + return 0 def main(): parser = argparse.ArgumentParser(description="ATLAS unit test runner",