4 """ Largely based on analysis/test/examples.py. """
14 from basf2
import find_file
15 from b2test_utils
import clean_working_directory
19 """ Test steering files """
23 Internal function to test a directory full of example scripts with an
24 optional list of broken scripts to be skipped.
27 path_to_glob (str): the path to search for scripts
28 broken (list(str)): (optional) scripts that are known to be broken
31 if additional_arguments
is None:
32 additional_arguments = []
35 all_egs = sorted(glob.glob(find_file(path_to_glob) +
"/*.py"))
37 filename = os.path.basename(eg)
38 if filename
not in broken:
39 with self.subTest(msg=filename):
40 result = subprocess.run(
41 [
"basf2",
"-n1", eg, *additional_arguments],
42 stdout=subprocess.PIPE,
43 stderr=subprocess.STDOUT,
45 if result.returncode != 0:
49 sys.stdout.buffer.write(result.stdout)
50 self.assertEqual(result.returncode, 0)
56 find_file(
"starterkit/2021/1111540100_eph3_BGx0_1.root",
"examples", silent=
True)
58 "Test data files not found."
60 def test_lessons_1_to_5(self):
62 "online_book/basf2/steering_files", additional_arguments=[
"1"]
66 if __name__ ==
"__main__":
67 with clean_working_directory():