11Simple launcher for decfiles/tests/test_changed_datfiles.py_noexec. This tests whether new decay files work for TauolaBelle2.
20from pathlib
import Path
23def add_hint(exit_code):
25 return "[ERROR] The given datfile can't be interpreted by basf2."
27 return "[ERROR] The given datfile contains value that doesn't exist yet."
29 return "[ERROR] The given datfile contains unknown value."
31 return "[ERROR] Unknown error occurred. Please Debug your Datfile"
34if __name__ ==
'__main__':
41 if not os.environ.get(
'BELLE2_LOCAL_DIR'):
44 topdir = Path(os.environ[
'BELLE2_LOCAL_DIR'])
45 assert topdir.is_dir()
49 merge_base = repo.merge_base(
'origin/main', repo.head)
52 diff_to_main = repo.head.commit.diff(merge_base)
54 added_or_modified_decfiles = [topdir / new_file.a_path
for new_file
in diff_to_main
55 if (Path(new_file.a_path).suffix ==
'.dat')
56 and (Path(
'decfiles/dec/TauolaBelle2')
in Path(new_file.a_path).parents)]
59 added_or_modified_decfiles = [decfile
for decfile
in added_or_modified_decfiles
60 if basf2.find_file(decfile.as_posix(), silent=
True)]
62 steering_file = basf2.find_file(
'decfiles/tests/test_changed_tauolabelle2.py_noexec')
65 if added_or_modified_decfiles:
66 changed_file_string =
'\n'.join(str(p)
for p
in added_or_modified_decfiles)
67 print(f
"Changed decayfiles: \n{changed_file_string}")
69 for decfile
in added_or_modified_decfiles:
71 run_results.append(subprocess.run([
'basf2', steering_file, str(decfile)], capture_output=
True))
77 files_and_errors = [f
'Decfile {added_or_modified_decfiles[i]} failed with output \n'
78 f
'{ret.stdout.decode()} \n and {add_hint(ret.returncode)}'
79 for i, ret
in enumerate(run_results)
80 if ret.returncode != 0
or (b
'5/ 5 events' not in ret.stdout
and ret.returncode == 0)]
82 if len(files_and_errors):
83 raise RuntimeError(
"At least one added decfile has failed.\n"
84 +
'\n'.join(files_and_errors))
def clean_working_directory()
def configure_logging_for_tests(user_replacements=None)
def skip_test(reason, py_case=None)