Skip to content

Commit 6c5372c

Browse files
authored
chore: Cleanup just recipes (#1031)
Replaces the machinery to call per-language instructions in the just recipes with simpler definitions. The main benefit is that now we can pass parameters to the internal commands, e.g. ```bash # Run rust tests matching the name just test-rust my_test --no-fail-fast # Run python tests matching the name just test-python -k some_other_test -vv ```
1 parent b7d9ee8 commit 6c5372c

File tree

1 file changed

+30
-35
lines changed

1 file changed

+30
-35
lines changed

justfile

Lines changed: 30 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -17,28 +17,42 @@ build:
1717
cd tket-py && uv run maturin build --release
1818

1919
# Run all the tests.
20-
test language="[rust|python]" : (_run_lang language \
21-
"uv run cargo test --all-features" \
22-
"uv run maturin develop --uv && uv run pytest"
23-
)
20+
test: test-rust test-python
21+
# Run all rust tests.
22+
test-rust *TEST_ARGS:
23+
uv run cargo test --all-features {{TEST_ARGS}}
24+
# Run all python tests.
25+
test-python *TEST_ARGS:
26+
uv run maturin develop --uv
27+
uv run pytest {{TEST_ARGS}}
2428

2529
# Auto-fix all clippy warnings.
26-
fix language="[rust|python]": (_run_lang language \
27-
"uv run cargo clippy --all-targets --all-features --workspace --fix --allow-staged --allow-dirty" \
28-
"uv run ruff check --fix"
29-
)
30+
fix: fix-rust fix-python
31+
# Auto-fix all rust clippy warnings.
32+
fix-rust:
33+
uv run cargo clippy --all-targets --all-features --workspace --fix --allow-staged --allow-dirty
34+
# Auto-fix all python clippy warnings.
35+
fix-python:
36+
uv run ruff check --fix
3037

3138
# Format the code.
32-
format language="[rust|python]": (_run_lang language \
33-
"uv run cargo fmt" \
34-
"uv run ruff format"
35-
)
39+
format: format-rust format-python
40+
# Format the rust code.
41+
format-rust:
42+
uv run cargo fmt
43+
# Format the python code.
44+
format-python:
45+
uv run ruff format
3646

3747
# Generate a test coverage report.
38-
coverage language="[rust|python]": (_run_lang language \
39-
"uv run cargo llvm-cov --lcov > lcov.info" \
40-
"uv run maturin develop && uv run pytest --cov=./ --cov-report=html"
41-
)
48+
coverage: coverage-rust coverage-python
49+
# Generate a test coverage report for the rust code.
50+
coverage-rust *TEST_ARGS:
51+
uv run cargo llvm-cov --lcov >lcov.info {{TEST_ARGS}}
52+
# Generate a test coverage report for the python code.
53+
coverage-python *TEST_ARGS:
54+
uv run maturin develop
55+
uv run pytest --cov=./ --cov-report=html {{TEST_ARGS}}
4256

4357
# Run Rust unsoundness checks using miri
4458
miri *TEST_ARGS:
@@ -55,22 +69,3 @@ gen-extensions:
5569
# Interactively update snapshot tests (requires `cargo-insta`)
5670
update-snapshots:
5771
cargo insta review
58-
59-
# Runs a rust and a python command, depending on the `language` variable.
60-
#
61-
# If `language` is set to `rust` or `python`, only run the command for that language.
62-
# Otherwise, run both commands.
63-
_run_lang language rust_cmd python_cmd:
64-
#!/usr/bin/env bash
65-
set -euo pipefail
66-
if [ "{{ language }}" = "rust" ]; then
67-
set -x
68-
{{ rust_cmd }}
69-
elif [ "{{ language }}" = "python" ]; then
70-
set -x
71-
{{ python_cmd }}
72-
else
73-
set -x
74-
{{ rust_cmd }}
75-
{{ python_cmd }}
76-
fi

0 commit comments

Comments
 (0)