-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpytest
98 lines (91 loc) · 3.78 KB
/
pytest
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#! /usr/bin/env python
import pathlib
# Inherit the parent construction environment
Import("env", "abaqus_environments", "cubit_environments")
# Limit list of source files to allow Conda build-test to test off the installed package
pytest_source_list = [
"pyproject.toml",
]
pytest_command = "cd turbo_turtle/ && pytest -n 4"
targets = env.Command(
target=["coverage.xml", Dir("./coverage")],
source=pytest_source_list,
action=[
(
"${pytest_command} -vvv -m 'not systemtest' --cov --cov-report=term "
"--cov-report=xml:${TARGETS[0].abspath} --cov-report=html:${TARGETS[1].abspath}"
)
],
pytest_command=pytest_command,
)
env.Alias("pytest", targets)
env.Clean("pytest", Dir("./coverage"))
env.Alias("regression", targets)
# Always run pytests in place of a complete source list
env.AlwaysBuild(targets)
# Cubit unit tests
for name, cubit_environment in cubit_environments.items():
targets = cubit_environment.Command(
target=[f"test_{name}_results.xml"],
source=pytest_source_list + ["turbo_turtle/tests/test_cubit_python.py"],
action=[
"${pytest_command} ${SOURCES[1].abspath} -vvv -m 'cubit_python' --cov --cov-report=xml:${TARGET.abspath}",
],
pytest_command=pytest_command,
)
cubit_environment.Alias("test_cubit_python", targets)
cubit_environment.Alias("regression", targets)
# Always run pytests in place of a complete source list
cubit_environment.AlwaysBuild(targets)
# Abaqus unit tests
for name, abaqus_environment in abaqus_environments.items():
source = [
"turbo_turtle/_abaqus_python/turbo_turtle_abaqus/test_abaqus_utilities.py",
"turbo_turtle/_abaqus_python/turbo_turtle_abaqus/test_mixed_utilities.py",
"turbo_turtle/_abaqus_python/turbo_turtle_abaqus/test_parsers.py",
"turbo_turtle/_abaqus_python/turbo_turtle_abaqus/test_vertices.py",
]
targets = abaqus_environment.Command(
target=[f"test_{name}_python.txt"],
source=source,
action=[
(
"PYTHONDONTWRITEBYTECODE=1 ${program} python -m unittest discover ${SOURCE.dir.abspath} --verbose "
"2>&1 | tee ${TARGET.abspath}"
)
],
program=abaqus_environment["abaqus"],
)
abaqus_environment.Alias("test_abaqus_python", targets)
abaqus_environment.Alias("regression", targets)
# Always run pytests in place of a complete source list
abaqus_environment.AlwaysBuild(targets)
# System tests
matrix = (
("and not require_third_party", "python3", {"python3": env}),
("and gmsh", "gmsh", {"gmsh": env}),
("and abaqus", "abaqus", abaqus_environments),
("and cubit", "cubit", cubit_environments),
)
for extra_markers, alias_suffix, environments in matrix:
for name, environment in environments.items():
source = pytest_source_list + [str(pathlib.Path("turbo_turtle/tests/test_system.py"))]
targets = env.Command(
target=[f"systemtest_{name}_results.xml"],
source=source,
action=[
(
"${pytest_command} -v --no-showlocals -m 'systemtest ${extra_markers}' --tb=short --cache-clear "
"--cov --cov-report=xml:${TARGET.abspath} "
"--abaqus-command=${abaqus_command} --cubit-command=${cubit_command}"
),
],
pytest_command=pytest_command,
extra_markers=extra_markers,
abaqus_command=environment["abaqus"] if "abaqus" in environment else None,
cubit_command=environment["cubit"] if "cubit" in environment else None,
)
env.Alias("systemtest", targets)
env.Alias(f"systemtest_{alias_suffix}", targets)
env.Alias("regression", targets)
env.AlwaysBuild(targets)