-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding test which checks for all the collections
- Loading branch information
Showing
4 changed files
with
59 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
if (nlohmann_json_FOUND) | ||
add_test(NAME convert_events | ||
COMMAND edm4hep2json ${CMAKE_CURRENT_BINARY_DIR}/../edm4hep_events.root) | ||
set_property(TEST convert_events PROPERTY DEPENDS write_events) | ||
set_test_env(convert_events) | ||
|
||
add_test(NAME test_convert_all_collections | ||
COMMAND python ${CMAKE_CURRENT_LIST_DIR}/test_all_collections.py | ||
${PROJECT_SOURCE_DIR}/edm4hep.yaml | ||
${PROJECT_SOURCE_DIR}/tools/include/edm4hep2json.hxx) | ||
set_test_env(test_convert_all_collections) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
''' | ||
Tests if all collection header files are included in the cxx file. | ||
''' | ||
|
||
import sys | ||
import argparse | ||
import yaml | ||
|
||
|
||
def test(yamlfile_path, cxxfile_path): | ||
''' | ||
Test itself. | ||
Takes two parameters, Podio YAML file location and cxx file to be checked. | ||
''' | ||
|
||
with open(yamlfile_path, mode='r', encoding="utf-8") as yamlfile: | ||
datamodel = yaml.safe_load(yamlfile) | ||
|
||
with open(cxxfile_path, mode='r', encoding="utf-8") as cxxfile: | ||
cxxfile_lines = cxxfile.readlines() | ||
|
||
datatypes = datamodel['datatypes'] | ||
|
||
for collname in datatypes: | ||
include_string = '#include "' + collname.replace('::', '/') + \ | ||
'Collection.h"' | ||
include_found = False | ||
for line in cxxfile_lines: | ||
if include_string in line: | ||
include_found = True | ||
|
||
if not include_found: | ||
print('ERROR: Following collection not included in the cxx file.') | ||
print(' ' + collname) | ||
sys.exit(2) | ||
|
||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser(description='Test all collections') | ||
parser.add_argument('yamlfile') | ||
parser.add_argument('cxxfile') | ||
args = parser.parse_args() | ||
|
||
test(args.yamlfile, args.cxxfile) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters