3Compiles and tests preCICE. Can be used with git bisect run or alike.
4Return 0 on success, 1 on failure and 125 on compilation failure which tells git bisect to skip that commit (neither mark it as good or bad)
6To ensure a clean test it can delete and recreate the ./build/TestOutput/ directories.
15parser = argparse.ArgumentParser(
16 formatter_class=argparse.ArgumentDefaultsHelpFormatter,
17 description=
"All additional arguments are passed to the testprecice binary.",
23 help=
"Source directory of preCICE",
30 help=
"Build directory of preCICE",
32 default=os.path.join(os.getcwd(),
"build"),
36 "-c",
"--compile", help=
"Compile preCICE", dest=
"compile", action=
"store_true"
41 help=
"Remove build/ and .scon* files before compiling",
48 help=
"Do not remove test directory for each test run",
52parser.add_argument(
"-t", help=
"Run tests.", dest=
"run_tests", action=
"store_true")
55 help=
"Number of CPUs to compile on",
57 default=multiprocessing.cpu_count(),
59parser.add_argument(
"--logconfig",
"-l", help=
"Log config file", default=
"")
66 except FileNotFoundError:
74args, remainder = parser.parse_known_args()
79 print(
"Wiping build directory ...")
82 os.makedirs(args.build_dir, exist_ok=
True)
84 CONFIGURE_CMD =
"cmake -DPRECICE_MPICommunication=ON -DPRECICE_PETScMapping=ON -DCMAKE_BUILD_TYPE=Debug {src}".format(
87 if subprocess.call(CONFIGURE_CMD, shell=
True, cwd=args.build_dir) != 0:
90 COMPILE_CMD =
"cmake --build {dir} -- -j {cpus}".format(
91 dir=args.build_dir, cpus=args.compile_cpus
93 if subprocess.call(COMPILE_CMD, shell=
True) != 0:
97 testbase = os.path.join(args.build_dir,
"TestOutput")
98 testdirs = [os.path.join(testbase, dir)
for dir
in next(os.walk(testbase))[1]]
99 if not args.keep_test:
100 print(
"Wiping test directories ...")
102 print(
"Wiping directory: {}".format(dir))
106 print(
"Copy ", args.logconfig,
" to test directories")
108 shutil.copyfile(args.logconfig, os.path.join(dir,
"log.conf"))
113 ret_code = subprocess.call(
114 "ctest -VV --output-on-failure", shell=
True, cwd=args.build_dir
117 if not ret_code == 0: