10We generate, simulate and reconstruct few events with two different processes
11and we check the two processes give exactly the same output.
19import b2test_utils
as b2tu
22def _unified_diff(expected, actual):
24 Helper function. Returns a string containing the unified diff of two multiline strings.
26 expected = expected.splitlines(1)
27 actual = actual.splitlines(1)
28 diff = difflib.unified_diff(expected, actual)
32if __name__ ==
'__main__':
34 steering = b2.find_file(
'reconstruction/tests/test_randomness.py_noexec')
35 command = f
'basf2 {steering} -n 10 --random-seed aSeed'
37 b2.B2INFO(
'Executing first job...')
38 with b2tu.clean_working_directory():
39 job1 = subprocess.run(command.split(), check=
True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=
True)
41 b2.B2INFO(
'Executing second job...')
42 with b2tu.clean_working_directory():
43 job2 = subprocess.run(command.split(), check=
True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=
True)
45 diff = _unified_diff(job1.stdout, job2.stdout)
47 b2.B2ERROR(
'!!! The two outputs are different !!!')
49 b2.B2FATAL(
'!!! basf2 produces irreproducible results !!!')