Skip to content

Commit 5141966

Browse files
committed
Test all from pixi task
+ only problem: FANS is run from global scope - if pixi global fans is there, that one is run....
1 parent ee5dd36 commit 5141966

9 files changed

+40
-202
lines changed

.github/workflows/pixi_build_mac.yaml

Lines changed: 0 additions & 52 deletions
This file was deleted.

test/pytest/conftest.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import pytest
2+
import os
3+
4+
def pytest_addoption(parser):
5+
parser.addoption(
6+
"--from-pixi", action="store_true", default=False,
7+
help="Run tests from pixi task."
8+
)
9+
10+
@pytest.fixture(
11+
params=[
12+
"test_J2Plasticity",
13+
"test_LinearElastic",
14+
"test_LinearThermal",
15+
"test_PseudoPlastic",
16+
]
17+
)
18+
def test_files(request):
19+
json_base_dir = os.path.join(
20+
os.path.dirname(os.path.abspath(__file__)), "../input_files/"
21+
)
22+
# Determine the HDF5 base directory based on the --from-pixi option
23+
# if run from pixi, use output directory; otherwise, use build/test directory, as it is the one used by ctest
24+
if request.config.getoption("--from-pixi"):
25+
h5_base_dir = os.path.join(
26+
os.path.dirname(os.path.abspath(__file__)), "../output"
27+
)
28+
else:
29+
h5_base_dir = os.path.join(
30+
os.path.dirname(os.path.abspath(__file__)), "../../build/test/"
31+
)
32+
33+
json_path = os.path.join(json_base_dir, f"{request.param}.json")
34+
h5_path = os.path.join(h5_base_dir, f"{request.param}.h5")
35+
36+
if os.path.exists(json_path) and os.path.exists(h5_path):
37+
return json_path, h5_path
38+
pytest.skip(f"Required test files not found: {json_path} or {h5_path}")

test/pytest/test_displacement_averaging.py

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,6 @@
44
import pytest
55
from fans_dashboard.core.utils import identify_hierarchy, extract_and_organize_data
66

7-
8-
@pytest.fixture(
9-
params=[
10-
"test_J2Plasticity",
11-
"test_LinearElastic",
12-
"test_LinearThermal",
13-
"test_PseudoPlastic",
14-
]
15-
)
16-
def test_files(request):
17-
json_base_dir = os.path.join(
18-
os.path.dirname(os.path.abspath(__file__)), "../input_files/"
19-
)
20-
h5_base_dir = os.path.join(
21-
os.path.dirname(os.path.abspath(__file__)), "../../build/test/"
22-
)
23-
24-
json_path = os.path.join(json_base_dir, f"{request.param}.json")
25-
h5_path = os.path.join(h5_base_dir, f"{request.param}.h5")
26-
27-
if os.path.exists(json_path) and os.path.exists(h5_path):
28-
return json_path, h5_path
29-
pytest.skip(f"Required test files not found: {json_path} or {h5_path}")
30-
31-
327
def test_displacement_averaging(test_files):
338
"""
349
This test verifies that the average of displacement fluctuations is zero for all

test/pytest/test_homogenization_consistency.py

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,6 @@
44
import pytest
55
from fans_dashboard.core.utils import identify_hierarchy, extract_and_organize_data
66

7-
8-
@pytest.fixture(
9-
params=[
10-
"test_J2Plasticity",
11-
"test_LinearElastic",
12-
"test_LinearThermal",
13-
"test_PseudoPlastic",
14-
]
15-
)
16-
def test_files(request):
17-
json_base_dir = os.path.join(
18-
os.path.dirname(os.path.abspath(__file__)), "../input_files/"
19-
)
20-
h5_base_dir = os.path.join(
21-
os.path.dirname(os.path.abspath(__file__)), "../../build/test/"
22-
)
23-
24-
json_path = os.path.join(json_base_dir, f"{request.param}.json")
25-
h5_path = os.path.join(h5_base_dir, f"{request.param}.h5")
26-
27-
if os.path.exists(json_path) and os.path.exists(h5_path):
28-
return json_path, h5_path
29-
pytest.skip(f"Required test files not found: {json_path} or {h5_path}")
30-
31-
327
def test_homogenization_consistency(test_files):
338
"""
349
This test verifies that the relationship stress_average = homogenized_tangent * strain_average

test/pytest/test_homogenized_tangent_spd.py

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,6 @@
55
from fans_dashboard.core.utils import identify_hierarchy, extract_and_organize_data
66
from scipy.linalg import eigvalsh
77

8-
9-
@pytest.fixture(
10-
params=[
11-
"test_J2Plasticity",
12-
"test_LinearElastic",
13-
"test_LinearThermal",
14-
"test_PseudoPlastic",
15-
]
16-
)
17-
def test_files(request):
18-
json_base_dir = os.path.join(
19-
os.path.dirname(os.path.abspath(__file__)), "../input_files/"
20-
)
21-
h5_base_dir = os.path.join(
22-
os.path.dirname(os.path.abspath(__file__)), "../../build/test/"
23-
)
24-
25-
json_path = os.path.join(json_base_dir, f"{request.param}.json")
26-
h5_path = os.path.join(h5_base_dir, f"{request.param}.h5")
27-
28-
if os.path.exists(json_path) and os.path.exists(h5_path):
29-
return json_path, h5_path
30-
pytest.skip(f"Required test files not found: {json_path} or {h5_path}")
31-
32-
338
def test_homogenized_tangent_spd(test_files):
349
"""
3510
This test verifies that the homogenized tangent is strictly Symmetric Positive Definite (SPD)

test/pytest/test_homogenized_tangent_within_VRbounds.py

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,31 +10,6 @@
1010
compute_volume_fractions,
1111
)
1212

13-
14-
@pytest.fixture(
15-
params=[
16-
"test_J2Plasticity",
17-
"test_LinearElastic",
18-
"test_LinearThermal",
19-
"test_PseudoPlastic",
20-
]
21-
)
22-
def test_files(request):
23-
json_base_dir = os.path.join(
24-
os.path.dirname(os.path.abspath(__file__)), "../input_files/"
25-
)
26-
h5_base_dir = os.path.join(
27-
os.path.dirname(os.path.abspath(__file__)), "../../build/test/"
28-
)
29-
30-
json_path = os.path.join(json_base_dir, f"{request.param}.json")
31-
h5_path = os.path.join(h5_base_dir, f"{request.param}.h5")
32-
33-
if os.path.exists(json_path) and os.path.exists(h5_path):
34-
return json_path, h5_path
35-
pytest.skip(f"Required test files not found: {json_path} or {h5_path}")
36-
37-
3813
def test_homogenized_tangent_within_VRbounds(test_files):
3914
"""
4015
This test verifies that the homogenized tangent is within Voigt and Reuss bounds

test/pytest/test_loading_to_strain_average.py

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,6 @@
44
import pytest
55
from fans_dashboard.core.utils import identify_hierarchy, extract_and_organize_data
66

7-
8-
@pytest.fixture(
9-
params=[
10-
"test_J2Plasticity",
11-
"test_LinearElastic",
12-
"test_LinearThermal",
13-
"test_PseudoPlastic",
14-
]
15-
)
16-
def test_files(request):
17-
json_base_dir = os.path.join(
18-
os.path.dirname(os.path.abspath(__file__)), "../input_files/"
19-
)
20-
h5_base_dir = os.path.join(
21-
os.path.dirname(os.path.abspath(__file__)), "../../build/test/"
22-
)
23-
24-
json_path = os.path.join(json_base_dir, f"{request.param}.json")
25-
h5_path = os.path.join(h5_base_dir, f"{request.param}.h5")
26-
27-
if os.path.exists(json_path) and os.path.exists(h5_path):
28-
return json_path, h5_path
29-
pytest.skip(f"Required test files not found: {json_path} or {h5_path}")
30-
31-
327
def test_loading_to_strain_average(test_files):
338
"""
349
This test verifies that the strain_average field in the results matches the macroscale_loading

test/pytest/test_strain_stress_averaging.py

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,6 @@
44
import pytest
55
from fans_dashboard.core.utils import identify_hierarchy, extract_and_organize_data
66

7-
8-
@pytest.fixture(
9-
params=[
10-
"test_J2Plasticity",
11-
"test_LinearElastic",
12-
"test_LinearThermal",
13-
"test_PseudoPlastic",
14-
]
15-
)
16-
def test_files(request):
17-
json_base_dir = os.path.join(
18-
os.path.dirname(os.path.abspath(__file__)), "../input_files/"
19-
)
20-
h5_base_dir = os.path.join(
21-
os.path.dirname(os.path.abspath(__file__)), "../../build/test/"
22-
)
23-
24-
json_path = os.path.join(json_base_dir, f"{request.param}.json")
25-
h5_path = os.path.join(h5_base_dir, f"{request.param}.h5")
26-
27-
if os.path.exists(json_path) and os.path.exists(h5_path):
28-
return json_path, h5_path
29-
pytest.skip(f"Required test files not found: {json_path} or {h5_path}")
30-
31-
327
def test_strain_stress_averaging(test_files):
338
"""
349
This test verifies that the average of strain/stress fields matches the strain_average/stress_average

test/run_tests.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ fi
1818
TIME_CMD="command time -v"
1919
[[ "$OSTYPE" == "darwin"* ]] && TIME_CMD="command gtime -v"
2020

21+
mkdir -p output
22+
2123
# Run the jobs serially
2224
$TIME_CMD mpiexec -n $num_processes "$FANS_EXEC" input_files/test_LinearThermal.json output/test_LinearThermal.h5 > test_LinearThermal.log 2>&1
2325

0 commit comments

Comments
 (0)