From 9bffcb3fb0bf9226b7202df1210adbf3bc414bca Mon Sep 17 00:00:00 2001 From: jmcarcell Date: Wed, 18 Dec 2024 22:11:01 +0100 Subject: [PATCH] Use CMake fixtures for tests that require other tests --- test/k4FWCoreTest/CMakeLists.txt | 53 +++++++++++++++++--------------- 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/test/k4FWCoreTest/CMakeLists.txt b/test/k4FWCoreTest/CMakeLists.txt index 0e7291e4..4302c583 100644 --- a/test/k4FWCoreTest/CMakeLists.txt +++ b/test/k4FWCoreTest/CMakeLists.txt @@ -63,9 +63,7 @@ function(add_test_with_env testname) if(arg STREQUAL "PROPERTIES") set(TEST_PROPERTIES_FOUND TRUE) elseif(arg STREQUAL "ADD_TO_CHECK_FILES") - get_property(CheckOutputFilesTest TEST FunctionalCheckFiles PROPERTY DEPENDS) - list(APPEND CheckOutputFilesTest ${testname}) - set_property(TEST FunctionalCheckFiles PROPERTY DEPENDS ${CheckOutputFilesTest}) + set(ADD_TO_CHECK_FILES TRUE) else() # For tests that depend on multiple tests and the original cmake way is to # add a colon between them this should make it work @@ -83,23 +81,28 @@ function(add_test_with_env testname) if(TEST_PROPERTIES_FOUND) set_tests_properties(${testname} PROPERTIES ${TEST_PROPERTIES}) endif() + if(ADD_TO_CHECK_FILES) + set_tests_properties(${testname} PROPERTIES FIXTURES_SETUP TestFiles) + endif() set_test_env(${testname}) endfunction() add_test(NAME FunctionalCheckFiles COMMAND python3 ${CMAKE_CURRENT_LIST_DIR}/scripts/CheckOutputFiles.py) +set_tests_properties(FunctionalCheckFiles PROPERTIES FIXTURES_REQUIRED TestFiles) add_test_with_env(CreateExampleEventData options/createExampleEventData.py) +set_tests_properties(CreateExampleEventData PROPERTIES FIXTURES_SETUP ExampleEventDataFile) add_test_with_env(CreateExampleEventDataInDirectory options/createExampleEventDataInDirectory.py) -add_test_with_env(CheckExampleEventData options/checkExampleEventData.py PROPERTIES DEPENDS CreateExampleEventData) -add_test_with_env(CheckExampleEventData_noCollections options/checkExampleEventData.py --collections= PROPERTIES DEPENDS CreateExampleEventData) +add_test_with_env(CheckExampleEventData options/checkExampleEventData.py PROPERTIES FIXTURES_REQUIRED ExampleEventDataFile) +add_test_with_env(CheckExampleEventData_noCollections options/checkExampleEventData.py --collections= PROPERTIES FIXTURES_REQUIRED ExampleEventDataFile) add_test_with_env(CheckExampleEventData_toolong options/checkExampleEventData.py -n 999 PROPERTIES PASS_REGULAR_EXPRESSION - "Application Manager Terminated successfully with a user requested ScheduledStop" DEPENDS CreateExampleEventData) + "Application Manager Terminated successfully with a user requested ScheduledStop" FIXTURES_REQUIRED ExampleEventDataFile) add_test_with_env(CheckExampleEventData_unbounded options/checkExampleEventData.py -n -1 PROPERTIES PASS_REGULAR_EXPRESSION - "Application Manager Terminated successfully with a user requested ScheduledStop" DEPENDS CreateExampleEventData) + "Application Manager Terminated successfully with a user requested ScheduledStop" FIXTURES_REQUIRED ExampleEventDataFile) add_test_with_env(ReadExampleEventData options/readExampleEventData.py) -set_property(TEST ReadExampleEventData APPEND PROPERTY DEPENDS CreateExampleEventData) -add_test_with_env(ReadExampleDataFromNthEvent options/readExampleDataFromNthEvent.py PROPERTIES DEPENDS CreateExampleEventData) +set_property(TEST ReadExampleEventData APPEND PROPERTY FIXTURES_REQUIRED ExampleEventDataFile) +add_test_with_env(ReadExampleDataFromNthEvent options/readExampleDataFromNthEvent.py PROPERTIES FIXTURES_REQUIRED ExampleEventDataFile) add_test_with_env(AlgorithmWithTFile options/TestAlgorithmWithTFile.py) set_property(TEST AlgorithmWithTFile PROPERTY WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}) @@ -147,17 +150,19 @@ add_test_with_env(FunctionalMemory options/ExampleFunctionalMemory.py) add_test_with_env(FunctionalMTMemory options/ExampleFunctionalMTMemory.py) add_test_with_env(FunctionalMultipleMemory options/ExampleFunctionalMultipleMemory.py) add_test_with_env(FunctionalProducer options/ExampleFunctionalProducer.py) +set_tests_properties(FunctionalProducer PROPERTIES FIXTURES_SETUP ProducerFile) add_test_with_env(FunctionalProducerAnother options/ExampleFunctionalProducer.py --second) add_test_with_env(FunctionalProducerMultiple options/ExampleFunctionalProducerMultiple.py) +set_tests_properties(FunctionalProducerMultiple PROPERTIES FIXTURES_SETUP ProducerMultipleFile) add_test_with_env(FunctionalProducerAbsolutePath options/ExampleFunctionalProducerAbsolutePath.py ADD_TO_CHECK_FILES) -add_test_with_env(FunctionalFile options/ExampleFunctionalFile.py PROPERTIES DEPENDS FunctionalProducer ADD_TO_CHECK_FILES) +add_test_with_env(FunctionalFile options/ExampleFunctionalFile.py PROPERTIES FIXTURES_REQUIRED ProducerFile ADD_TO_CHECK_FILES) add_test_with_env(FunctionalSeveralInputFiles options/ExampleFunctionalSeveralInputFiles.py) set_tests_properties(FunctionalSeveralInputFiles PROPERTIES DEPENDS "FunctionalProducer;FunctionalProducerAnother") -add_test_with_env(FunctionalMTFile options/ExampleFunctionalMTFile.py PROPERTIES DEPENDS FunctionalProducer ADD_TO_CHECK_FILES) -add_test_with_env(FunctionalMultipleFile options/ExampleFunctionalFileMultiple.py PROPERTIES DEPENDS FunctionalProducerMultiple ADD_TO_CHECK_FILES) -add_test_with_env(FunctionalMix options/runFunctionalMix.py PROPERTIES DEPENDS FunctionalProducerMultiple ADD_TO_CHECK_FILES) -add_test_with_env(FunctionalMixIOSvc options/runFunctionalMix.py --iosvc PROPERTIES DEPENDS FunctionalProducerMultiple ADD_TO_CHECK_FILES) -add_test_with_env(FunctionalOutputCommands options/ExampleFunctionalOutputCommands.py PROPERTIES DEPENDS FunctionalProducerMultiple ADD_TO_CHECK_FILES) +add_test_with_env(FunctionalMTFile options/ExampleFunctionalMTFile.py PROPERTIES FIXTURES_REQUIRED ProducerFile ADD_TO_CHECK_FILES) +add_test_with_env(FunctionalMultipleFile options/ExampleFunctionalFileMultiple.py PROPERTIES FIXTURES_REQUIRED ProducerMultipleFile ADD_TO_CHECK_FILES) +add_test_with_env(FunctionalMix options/runFunctionalMix.py PROPERTIES FIXTURES_REQUIRED ProducerMultipleFile ADD_TO_CHECK_FILES) +add_test_with_env(FunctionalMixIOSvc options/runFunctionalMix.py --iosvc PROPERTIES FIXTURES_REQUIRED ProducerMultipleFile ADD_TO_CHECK_FILES) +add_test_with_env(FunctionalOutputCommands options/ExampleFunctionalOutputCommands.py PROPERTIES FIXTURES_REQUIRED ProducerMultipleFile ADD_TO_CHECK_FILES) add_test_with_env(FunctionalConsumerRuntimeCollections options/ExampleFunctionalConsumerRuntimeCollections.py) add_test_with_env(FunctionalConsumerRuntimeCollectionsMultiple options/ExampleFunctionalConsumerRuntimeCollectionsMultiple.py) add_test_with_env(FunctionalProducerRuntimeCollections options/ExampleFunctionalProducerRuntimeCollections.py) @@ -165,7 +170,7 @@ add_test_with_env(FunctionalTransformerRuntimeCollections options/ExampleFunctio add_test_with_env(FunctionalTransformerRuntimeEmpty options/ExampleFunctionalTransformerRuntimeEmpty.py ADD_TO_CHECK_FILES) add_test_with_env(FunctionalTransformerRuntimeCollectionsMultiple options/ExampleFunctionalTransformerRuntimeCollectionsMultiple.py) add_test_with_env(FunctionalTransformerHist options/ExampleFunctionalTransformerHist.py ADD_TO_CHECK_FILES) -add_test_with_env(FunctionalCollectionMerger options/ExampleFunctionalCollectionMerger.py PROPERTIES DEPENDS FunctionalProducerMultiple ADD_TO_CHECK_FILES) +add_test_with_env(FunctionalCollectionMerger options/ExampleFunctionalCollectionMerger.py PROPERTIES FIXTURES_REQUIRED ProducerMultipleFile ADD_TO_CHECK_FILES) add_test_with_env(FunctionalFilterFile options/ExampleFunctionalFilterFile.py ADD_TO_CHECK_FILES) add_test_with_env(FunctionalMetadata options/ExampleFunctionalMetadata.py ADD_TO_CHECK_FILES) add_test_with_env(FunctionalMetadataRead options/ExampleFunctionalMetadataRead.py PROPERTIES DEPENDS FunctionalMetadata ADD_TO_CHECK_FILES) @@ -174,21 +179,21 @@ add_test_with_env(createEventHeaderConcurrent options/createEventHeaderConcurren add_test_with_env(FunctionalMetadataReadOldAlgorithm options/ExampleFunctionalMetadataReadOldAlgorithm.py PROPERTIES DEPENDS FunctionalMetadataOldAlgorithm ADD_TO_CHECK_FILES) add_test_with_env(FunctionalNonExistingFile options/ExampleFunctionalNonExistingFile.py) set_tests_properties(FunctionalNonExistingFile PROPERTIES PASS_REGULAR_EXPRESSION "File.*couldn't be found") -add_test_with_env(FunctionalNonExistingFileOverwritten options/ExampleFunctionalNonExistingFile.py --IOSvc.Input functional_producer.root PROPERTIES DEPENDS FunctionalProducer) -add_test_with_env(FunctionalFileTooLong options/ExampleFunctionalFile.py -n 999 --IOSvc.Output toolong.root PROPERTIES DEPENDS FunctionalProducer PASS_REGULAR_EXPRESSION +add_test_with_env(FunctionalNonExistingFileOverwritten options/ExampleFunctionalNonExistingFile.py --IOSvc.Input functional_producer.root PROPERTIES FIXTURES_REQUIRED ProducerFile) +add_test_with_env(FunctionalFileTooLong options/ExampleFunctionalFile.py -n 999 --IOSvc.Output toolong.root PROPERTIES FIXTURES_REQUIRED ProducerFile PASS_REGULAR_EXPRESSION "Application Manager Terminated successfully with a user requested ScheduledStop") -add_test_with_env(FunctionalFileTooShort options/ExampleFunctionalFile.py -n 2 --IOSvc.Output two_events.root PROPERTIES DEPENDS FunctionalProducer ADD_TO_CHECK_FILES) +add_test_with_env(FunctionalFileTooShort options/ExampleFunctionalFile.py -n 2 --IOSvc.Output two_events.root PROPERTIES FIXTURES_REQUIRED ProducerFile ADD_TO_CHECK_FILES) add_test_with_env(FunctionalFileCLI options/ExampleFunctionalNoFile.py --IOSvc.Input functional_producer.root --IOSvc.Output functional_transformer_cli.root ADD_TO_CHECK_FILES) -set_tests_properties(FunctionalFileCLI PROPERTIES DEPENDS FunctionalProducer) +set_tests_properties(FunctionalFileCLI PROPERTIES FIXTURES_REQUIRED ProducerFile) add_test_with_env(FunctionalFileCLIMultiple options/ExampleFunctionalNoFile.py --IOSvc.Input functional_producer.root functional_producer.root --IOSvc.Output functional_transformer_cli_multiple.root -n -1 ADD_TO_CHECK_FILES) -set_tests_properties(FunctionalFileCLIMultiple PROPERTIES DEPENDS FunctionalProducer) +set_tests_properties(FunctionalFileCLIMultiple PROPERTIES FIXTURES_REQUIRED ProducerFile) add_test_with_env(FunctionalWrongImport options/ExampleFunctionalWrongImport.py) set_tests_properties(FunctionalWrongImport PROPERTIES PASS_REGULAR_EXPRESSION "ImportError: Importing ApplicationMgr or IOSvc from Configurables is not allowed.") -add_test_with_env(FunctionalReadNthEvent options/ExampleFunctionalReadNthEvent.py PROPERTIES DEPENDS FunctionalProducer ADD_TO_CHECK_FILES) +add_test_with_env(FunctionalReadNthEvent options/ExampleFunctionalReadNthEvent.py PROPERTIES FIXTURES_REQUIRED ProducerFile ADD_TO_CHECK_FILES) add_test_with_env(FunctionalProducerRNTuple options/ExampleFunctionalProducerRNTuple.py ADD_TO_CHECK_FILES) -add_test_with_env(FunctionalTTreeToRNTuple options/ExampleFunctionalTTreeToRNTuple.py PROPERTIES DEPENDS FunctionalProducer ADD_TO_CHECK_FILES) -add_test_with_env(GaudiFunctional options/ExampleGaudiFunctional.py PROPERTIES DEPENDS FunctionalProducer ADD_TO_CHECK_FILES) +add_test_with_env(FunctionalTTreeToRNTuple options/ExampleFunctionalTTreeToRNTuple.py PROPERTIES FIXTURES_REQUIRED ProducerFile ADD_TO_CHECK_FILES) +add_test_with_env(GaudiFunctional options/ExampleGaudiFunctional.py PROPERTIES FIXTURES_REQUIRED ProducerFile ADD_TO_CHECK_FILES) # The following is done to make the tests work without installing the files in