-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjustfile
More file actions
219 lines (177 loc) · 8.47 KB
/
justfile
File metadata and controls
219 lines (177 loc) · 8.47 KB
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
[private]
default: (watch "dev")
# Watch files for changes and run the provided `just` command when there's a change. Typically used as `just watch dev`.
[group("General Commands")]
watch command:
watchexec just {{ command }}
# Format code, run tests, generate coverage, and run clippy. Typically used via `just watch dev`.
[group("General Commands")]
dev: format check coverage clippy expansion-tests doc
# Build documentation for libraries.
[group("General Commands")]
doc:
cargo doc --locked --lib --no-deps
# Generate the book and open in your default browser.
[group("General Commands")]
book:
mdbook serve --open
# Generate the book.
[group("General Commands")]
book-build:
mdbook build
# Update expected output for broken and expansion tests to the current output.
[group("General Commands")]
update-test-output:
# Update broken test results
TRYBUILD=overwrite just run-against-broken "cargo test --locked"
# Update config test output
[ ! -f ./oxiplate-derive/tests/config/crates/*/tests/broken/*.stderr ] || cp ./oxiplate-derive/tests/config/crates/*/tests/broken/*.stderr ./oxiplate-derive/tests/config/expected/
# Update expansion test results
cargo test --locked --test expansion --features better-errors --no-fail-fast -- --ignored || true
[ ! -f ./oxiplate/tests/expansion/actual/*.rs ] || mv ./oxiplate/tests/expansion/actual/*.rs ./oxiplate/tests/expansion/expected/
[ ! -f ./oxiplate-derive/tests/expansion/actual/*.rs ] || mv ./oxiplate-derive/tests/expansion/actual/*.rs ./oxiplate-derive/tests/expansion/expected/
echo "Test output updated successfully!"
# Rebuild test crates for config
[group("General Commands")]
rebuild-config-test-crates:
cargo run --bin oxiplate-derive-test-config
cargo update --workspace
# Run book tests.
book-tests:
cargo build --package oxiplate --target-dir target/book/
RUSTUP_TOOLCHAIN="nightly-2026-03-25" CARGO_MANIFEST_DIR=`pwd`/book/lib mdbook test --library-path target/book/debug/deps
# Format code.
[group("Lint")]
format: && (format-broken "rustfmt")
cargo fmt
# Check if code is formatted properly. Use `just format` to format automatically.
[group("Lint")]
format-check: && (format-broken "rustfmt --check")
cargo fmt --check
# Format Rust files in each `/broken/` directory
[private]
[group("Lint")]
format-broken command:
find -type d -name broken -print0 | xargs -0 -I{} find '{}' -name '*.rs' -print0 | xargs -0 -n 999 {{ command }}
# Run `cargo clippy` against all packages.
[group("Lint")]
clippy:
cargo clippy --locked --workspace
# Run check against all packages.
[group("Test")]
check: (run-against-stable "cargo check --locked" "") (run-against-unstable "cargo check --locked" "")
# Run check against all packages, denying warnings.
[group("Test")]
check-strict: (run-against-stable "RUSTFLAGS='-D warnings' cargo check --locked" "") (run-against-unstable "RUSTFLAGS='-D warnings' cargo check --locked" "")
# Check dependencies for licenses, bans, and sources
[group("Test")]
check-deps:
cargo deny check licenses bans sources
# Run tests without coverage.
[group("Test")]
test: (run-against-all "cargo test --locked") build-no-std (run-against-libs "cargo test --locked --doc") book-tests expansion-tests
cargo test --package oxiplate-derive --test clippy -- --ignored
# Run stable tests against specified toolchain (target triples not supported).
[group("Test")]
[arg("toolchain", pattern='(stable|beta|nightly|\d+\.\d+(\.\d+)?(-beta(\.\d+)?)?)(-\d{4}-\d{2}-\d{2})?')]
test-toolchain toolchain: && (run-against-stable f"cargo +{{ toolchain }} test --locked") (build-no-std toolchain)
@echo "Running tests against {{ toolchain }} toolchain..."
# Run stable tests against `rust-version` listed in `/Cargo.toml`.
[group("Test")]
test-msrv: (test-toolchain `just get-msrv`)
# Build `oxiplate` against a target with no `std`
[group("Test")]
[arg("toolchain", pattern='((stable|beta|nightly|\d+\.\d+(\.\d+)?(-beta(\.\d+)?)?)(-\d{4}-\d{2}-\d{2})?)?')]
build-no-std toolchain="":
RUSTFLAGS='-D warnings' cargo {{ if toolchain != "" { '+' + toolchain } else { '' } }} build --locked --target=x86_64-unknown-none --package oxiplate
[private]
get-msrv:
@cargo metadata --no-deps --format-version 1 \
| jq --join-output '.packages[] | select(.name == "oxiplate") | .rust_version'
# Build HTML and LCOV reports from running tests with coverage.
[group("Test")]
coverage: coverage-lcov coverage-html
# Build LCOV report from running tests with coverage.
[group("Test")]
coverage-lcov: coverage-no-report
cargo llvm-cov report --lcov --output-path lcov.info
# Build HTML report from running tests with coverage.
[group("Test")]
coverage-html: coverage-no-report
cargo llvm-cov report --html
# Build LCOV report for each package from running tests with coverage.
[group("Test")]
coverage-lcov-packages: coverage-no-report \
(coverage-lcov-package "oxiplate" "oxiplate-derive|oxiplate-traits") \
(coverage-lcov-package "oxiplate-derive" "oxiplate|oxiplate-traits") \
(coverage-lcov-package "oxiplate-traits" "oxiplate|oxiplate-derive")
[private]
[group("Test")]
coverage-lcov-package package other-packages: coverage-no-report
cargo llvm-cov report --ignore-filename-regex "^$PWD/({{ other-packages }})/" --lcov --output-path {{ package }}.lcov
# Run tests with coverage without building a report. Typically used with `cargo llvm-cov report`.
[group("Test")]
coverage-no-report: clean-coverage \
(run-against-all "cargo llvm-cov --no-report --locked --no-rustc-wrapper") \
(run-against-libs "cargo llvm-cov --no-report --locked --no-rustc-wrapper --doc")
cargo test --package oxiplate-derive --test clippy -- --ignored
[private]
expansion-tests:
cargo test --locked --test expansion --features better-errors -- --ignored
[private]
clean-coverage:
cargo llvm-cov clean --workspace
[private]
run-against-libs command test-arguments="":
{{ command }} --package oxiplate-derive -- {{ test-arguments }}
{{ command }} --workspace \
--exclude oxiplate-derive \
--exclude oxiplate-derive-test-unreachable \
--exclude oxiplate-derive-test-unreachable-stable \
--exclude oxiplate-test-fast-escape-type-priority \
--exclude oxiplate-test-file-extension-inferrence-off \
--exclude oxiplate-test-slow-escape-ints \
--exclude oxiplate-test-unreachable \
--exclude oxiplate-test-unreachable-stable -- {{ test-arguments }}
[private]
run-against-all command test-arguments="": (run-against-stable command test-arguments) (run-against-unstable command test-arguments) check-strict (run-against-broken command)
# Tests that can be run against the MSRV in `/Cargo.toml`
# and the nightly specified in `/rust-toolchain.toml`.
[private]
run-against-stable command test-arguments="": (run-against-libs command test-arguments)
{{ command }} --package oxiplate-test-fast-escape-type-priority -- {{ test-arguments }}
{{ command }} --package oxiplate-test-slow-escape-ints -- {{ test-arguments }}
# Tests requiring unstable features that cannot be run against the MSRV.
[private]
run-against-unstable command test-arguments="":
{{ command }} --package oxiplate-test-unreachable -- {{ test-arguments }}
{{ command }} --package oxiplate-test-unreachable-stable -- {{ test-arguments }}
{{ command }} --package oxiplate-test-file-extension-inferrence-off -- {{ test-arguments }}
{{ command }} --package oxiplate-derive-test-unreachable -- {{ test-arguments }}
{{ command }} --package oxiplate-derive-test-unreachable-stable -- {{ test-arguments }}
# Tests for broken compilations.
[private]
run-against-broken command: (run-against-libs f"{{ command }} --test broken --features external-template-spans" "--ignored") (run-against-unstable f"{{ command }} --test broken" "--ignored")
# Initial setup. Run once to install all necessary binaries. Run again to ensure they are all up-to-date.
[group("Setup"), group("General Commands")]
setup: setup-dev setup-test setup-expansion setup-coverage setup-book
# Initial setup for general development.
[group("Setup")]
setup-dev:
cargo install just watchexec-cli
# Initial setup for testing
[group("Setup")]
setup-test:
cargo install --locked cargo-deny@0.19.0
# Initial setup for expansion tests and debugging.
[group("Setup")]
setup-expansion:
cargo install cargo-expand
# Initial setup for test coverage.
[group("Setup")]
setup-coverage: setup-test
cargo install cargo-llvm-cov
# Initial setup for generating the book.
[group("Setup")]
setup-book:
cargo install mdbook@0.4.52 mdbook-codename