Skip to content

Commit 35bdc63

Browse files
committed
testing
1 parent 4d2ed3a commit 35bdc63

File tree

3 files changed

+43
-2
lines changed

3 files changed

+43
-2
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -695,4 +695,4 @@ jobs:
695695
- name: Run tests
696696
if: steps.wheels-presence.outputs.found == 'true'
697697
run: |
698-
just test-package -v
698+
just test-package -v -k 'test_package or test_plain_dictation'

Justfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11

2+
set ignore-comments
23
set positional-arguments
34

45
docker_repo := 'daanzu/kaldi-fork-active-grammar-manylinux'
@@ -57,4 +58,5 @@ test *args='':
5758

5859
# Test package after building wheel into wheels/ directory. Runs tests from within tests/ directory to prevent importing kaldi_active_grammar from source tree
5960
test-package *args='':
60-
uv run -v --no-project --isolated --with-requirements ../requirements-test.txt --with kaldi-active-grammar --find-links wheels/ --directory tests/ -m pytest "$@"
61+
# uv run -v --no-project --isolated --with-requirements ../requirements-test.txt --with kaldi-active-grammar --find-links wheels/ --directory tests/ -m pytest "$@"
62+
uv run -v --no-project --isolated --with-requirements ../requirements-test.txt --with kaldi-active-grammar --find-links wheels/ --directory tests/ run_each_test_separately.py "$@"

tests/run_each_test_separately.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
"""
2+
Run each test in a separate process.
3+
This is the only reasonable cross-platform way to do this with pytest.
4+
"""
5+
6+
import sys, subprocess
7+
8+
def collect_nodeids(extra):
9+
# -q with --collect-only prints one nodeid per line
10+
r = subprocess.run(
11+
[sys.executable, "-m", "pytest", "-q", "--collect-only", *extra],
12+
capture_output=True, text=True, check=True
13+
)
14+
return [
15+
ln.strip().split("/")[-1] # Discard the "tests/" prefix
16+
for ln in r.stdout.splitlines()
17+
if ln.strip() and not ln.startswith(("=", "<", "[")) and not "collected in" in ln
18+
]
19+
20+
def main():
21+
extra = sys.argv[1:] # e.g. ["tests", "-k", "not slow"]
22+
nodeids = collect_nodeids(extra)
23+
print(f"Collected {len(nodeids)} nodeids: {nodeids}")
24+
failed = []
25+
for nid in nodeids:
26+
print(f"\n=== {nid} ===")
27+
rc = subprocess.call([sys.executable, "-m", "pytest", "-q", nid, *extra])
28+
if rc != 0:
29+
failed.append(nid)
30+
print("\n========= DONE =========")
31+
if failed:
32+
print(f"\nFailures in {len(failed)} tests:")
33+
for nid in failed: print(" -", nid)
34+
sys.exit(1)
35+
else:
36+
print("\nAll tests passed.")
37+
38+
if __name__ == "__main__":
39+
main()

0 commit comments

Comments
 (0)