678058c940
CI / Select checks (push) Has been cancelled
CI / Format and repository checks (push) Has been cancelled
CI / Compile RISC-V (manual) (push) Has been cancelled
Docker / image (push) Has been cancelled
Generated files / Regenerate and commit (push) Has been cancelled
Kernel rig / Select the rig areas (push) Has been cancelled
Lists / Design format changes merge cleanly (push) Has been cancelled
Lists / Lists are sorted one item per line (push) Has been cancelled
Packaging lint / lint (push) Has been cancelled
Pages / build (push) Has been cancelled
CI / Dependency advisories (push) Has been cancelled
CI / Quick compile (push) Has been cancelled
CI / Native Linux Clippy (push) Has been cancelled
CI / Build tests (push) Has been cancelled
CI / Native Linux tests (push) Has been cancelled
CI / GPU path tests (1/4) (push) Has been cancelled
CI / GPU path tests (2/4) (push) Has been cancelled
CI / GPU path tests (3/4) (push) Has been cancelled
CI / GPU path tests (4/4) (push) Has been cancelled
CI / Action matrix (1/16) (push) Has been cancelled
CI / Action matrix (10/16) (push) Has been cancelled
CI / Action matrix (11/16) (push) Has been cancelled
CI / Action matrix (12/16) (push) Has been cancelled
CI / Action matrix (13/16) (push) Has been cancelled
CI / Action matrix (14/16) (push) Has been cancelled
CI / Action matrix (15/16) (push) Has been cancelled
CI / Action matrix (16/16) (push) Has been cancelled
CI / Action matrix (2/16) (push) Has been cancelled
CI / Action matrix (3/16) (push) Has been cancelled
CI / Action matrix (4/16) (push) Has been cancelled
CI / Action matrix (5/16) (push) Has been cancelled
CI / Action matrix (6/16) (push) Has been cancelled
CI / Action matrix (7/16) (push) Has been cancelled
CI / Action matrix (8/16) (push) Has been cancelled
CI / Action matrix (9/16) (push) Has been cancelled
CI / Action matrix determinism (push) Has been cancelled
CI / Property tests (many cases) (push) Has been cancelled
CI / Doc tests (push) Has been cancelled
CI / Reference tests (push) Has been cancelled
CI / Windows D3D12 FXC shaders (push) Has been cancelled
CI / Windows app startup (push) Has been cancelled
CI / ci (push) Has been cancelled
CI / Compile WebAssembly (push) Has been cancelled
CI / Nightly alert (push) Has been cancelled
Kernel rig / Build the CLI (push) Has been cancelled
Kernel rig / Kernel rig (${{ matrix.shard }}) (push) Has been cancelled
Kernel rig / kernel-rig (push) Has been cancelled
Pages / deploy (push) Has been cancelled
67 lines
2.3 KiB
Python
67 lines
2.3 KiB
Python
import subprocess
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
SCRIPTS = Path(__file__).parents[1]
|
|
sys.path.insert(0, str(SCRIPTS))
|
|
import run # noqa: E402
|
|
|
|
|
|
def cube_step(path: Path, x: float) -> Path:
|
|
run.execute([
|
|
{"command": "solid.box", "params": {"length": 10, "width": 10, "height": 10, "body_name": "Cube"}},
|
|
{"command": "solid.move", "params": {"bodies": ["Cube"], "translate": [x, 0, 0]}},
|
|
{"command": "file.export", "params": {"path": str(path), "bodies": ["Cube"]}},
|
|
])
|
|
return path
|
|
|
|
|
|
@pytest.fixture
|
|
def cubes(tmp_path):
|
|
return cube_step(tmp_path / "a.step", 0), cube_step(tmp_path / "b.step", 1)
|
|
|
|
|
|
def compare(*args):
|
|
return subprocess.run([sys.executable, SCRIPTS / "compare_step.py", *args], capture_output=True, text=True)
|
|
|
|
|
|
def test_identical_solids_have_no_difference(cubes):
|
|
a, _ = cubes
|
|
result = compare(a, a)
|
|
assert result.returncode == 0, result.stderr
|
|
assert "xor 0 mm3" in result.stdout
|
|
|
|
|
|
def test_shifted_solid_shows_where_it_differs(cubes):
|
|
a, b = cubes
|
|
result = compare(b, a)
|
|
assert result.returncode == 1, result.stderr
|
|
assert "xor 200 mm3 in 2 pieces" in result.stdout
|
|
assert "only in actual: 100 mm3 at (10, 0, 0)..(11, 10, 10)" in result.stdout
|
|
assert "only in expected: 100 mm3 at (0, 0, 0)..(1, 10, 10)" in result.stdout
|
|
|
|
|
|
def test_tolerance(cubes):
|
|
a, b = cubes
|
|
result = compare(b, a, "--tolerance", "500")
|
|
assert result.returncode == 0, result.stderr
|
|
assert "xor 200 mm3 in 2 pieces" in result.stdout
|
|
|
|
|
|
def two_boxes_step(path: Path, shift: float) -> Path:
|
|
run.execute([
|
|
{"command": "solid.box", "params": {"length": 10, "width": 10, "height": 10, "body_name": "A"}},
|
|
{"command": "solid.box", "params": {"length": 10, "width": 10, "height": 10, "body_name": "B"}},
|
|
{"command": "solid.move", "params": {"bodies": ["B"], "translate": [shift, 0, 0]}},
|
|
{"command": "file.export", "params": {"path": str(path), "bodies": ["A", "B"]}},
|
|
])
|
|
return path
|
|
|
|
|
|
def test_overlapping_solids_in_one_file_count_once(tmp_path):
|
|
result = compare(two_boxes_step(tmp_path / "a.step", 5), two_boxes_step(tmp_path / "b.step", 10))
|
|
assert "volume 1500 vs 2000 mm3" in result.stdout, result.stdout + result.stderr
|
|
assert "xor 500 mm3" in result.stdout
|