-
Notifications
You must be signed in to change notification settings - Fork 2
/
launch_integration_tests.py
executable file
·64 lines (56 loc) · 1.96 KB
/
launch_integration_tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env python
"""
This program launches the integration tests suite
"""
from contextlib import contextmanager
import os
from pathlib import Path
import subprocess
import sys
from typing import List
@contextmanager
def down_to_directory(directory: Path) -> None:
"""
A context manager that descends into the directory and returns to the original one
"""
current_path = os.getcwd()
os.chdir(directory.as_posix())
yield
os.chdir(current_path)
def get_integration_tests() -> List[Path]:
"""
Returns the list of paths toward integration tests directories
"""
integration_tests = []
integration_root = Path("./xfv/tests/integration")
for root, _, files in os.walk(integration_root.as_posix()):
if 'XDATA.json' in files:
integration_tests.append(Path(root))
return integration_tests
def launch_integration_test() -> bool:
"""
Launch the integration test and return True if everything is ok. False otherwise.
"""
launch_cmd = f"XtendedFiniteVolume.py {os.getcwd()} --use-internal-solver"
print(f"Executing command: {launch_cmd}")
try:
subprocess.check_output(launch_cmd.split())
except subprocess.CalledProcessError:
print(f"The command {launch_cmd} has failed!", file=sys.stderr)
return False
compar_cmd = "h5diff -r reference.hdf5 all_fields.hdf5"
print(f"Executing command: {compar_cmd}")
try:
subprocess.check_output(compar_cmd.split())
except subprocess.CalledProcessError:
print("Differences are detected between reference and obtained results!")
return False
print("=> Test OK : no differences detected!")
return True
if __name__ == "__main__":
for integration_test in get_integration_tests():
with down_to_directory(integration_test):
print(f"Launching the integration test {integration_test.as_posix()}")
if not launch_integration_test():
sys.exit(1)
sys.exit(0)