Skip to content

Commit a8476e1

Browse files
committed
Simplify and speed up metadata query for journey tests
The journey tests need to know where the target directory is. For robustness, we have not been assuming it is `target`, but instead attempting to allow it to be in any location, and querying cargo metadata to find out where it is. (Doing so has the effect of taking care of resolving it to an absolute path, too.) This preserves that, and continues to use `justfile` logic to find it, but does so in a more streamlined way: - Pass `--no-deps` to `cargo metadata`, since dependencies should not affect the location of the target directory. - In the `jq` command that processes `cargo metadata` output, pass `-e`/`--exit-status` so `jq` reports a failing status if the query fails (such as by attempting to look up a missing key, due to `cargo metadata` having failed or otherwise not producing the expected kind of output). - For `jq`, express `-r` as `--raw-output (and `-e` as `--exit-status`) so that the meaning is more readily clear. - Extract a generalized `cargo metadata ... | jq ...` recipe with the flags we're using on both commands. This is parameterized on the `jq` query argument only. This is to make the code easier to read, and also in anticipation of other uses that would also want those flags and no others but with different query strings (such as to extract the MSRV). And removes checks that are now unnecessary: - Don't do a separate check for empty `jq` output anymore, since the goal is to check for an absent key (or totally empty input), and `-e`/`--exit-status` takes care of that. - Don't repeat `dbg` as a prerequisite for the journey test recipes that rely on it, instead allowing the recipes to proceed until they get to where they really use it (which is by interpolation), because `--no-deps` should avoid any major delays at this point as well as making failure unlikely (but if it does fail, that is still checked and will still fail the recipe).
1 parent a943e36 commit a8476e1

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

justfile

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -184,34 +184,36 @@ unit-tests:
184184
unit-tests-flaky:
185185
cargo test -p gix --features async-network-client-async-std
186186

187-
# Depend on this to pre-generate metadata, and/or use it inside a recipe as `"$({{ j }} dbg)"`
187+
# Extract cargo metadata, excluding dependencies, and query it
188+
[private]
189+
get-metadata jq-query:
190+
cargo metadata --format-version 1 | jq --exit-status --raw-output -- {{ quote(jq-query) }}
191+
192+
# Get the path to the directory where debug binaries are created during builds
188193
[private]
189194
dbg:
190-
set -eu; \
191-
target_dir="$(cargo metadata --format-version 1 | jq -r .target_directory)"; \
192-
test -n "$target_dir"; \
193-
echo "$target_dir/debug"
195+
target_dir="$({{ j }} get-metadata .target_directory)" && echo "$target_dir/debug"
194196

195197
# Run journey tests (`max`)
196-
journey-tests: dbg
198+
journey-tests:
197199
cargo build --features http-client-curl-rustls
198200
cargo build -p gix-testtools --bin jtt
199201
dbg="$({{ j }} dbg)" && tests/journey.sh "$dbg/ein" "$dbg/gix" "$dbg/jtt" max
200202

201203
# Run journey tests (`max-pure`)
202-
journey-tests-pure: dbg
204+
journey-tests-pure:
203205
cargo build --no-default-features --features max-pure
204206
cargo build -p gix-testtools --bin jtt
205207
dbg="$({{ j }} dbg)" && tests/journey.sh "$dbg/ein" "$dbg/gix" "$dbg/jtt" max-pure
206208

207209
# Run journey tests (`small`)
208-
journey-tests-small: dbg
210+
journey-tests-small:
209211
cargo build --no-default-features --features small
210212
cargo build -p gix-testtools
211213
dbg="$({{ j }} dbg)" && tests/journey.sh "$dbg/ein" "$dbg/gix" "$dbg/jtt" small
212214

213215
# Run journey tests (`lean-async`)
214-
journey-tests-async: dbg
216+
journey-tests-async:
215217
cargo build --no-default-features --features lean-async
216218
cargo build -p gix-testtools
217219
dbg="$({{ j }} dbg)" && tests/journey.sh "$dbg/ein" "$dbg/gix" "$dbg/jtt" async

0 commit comments

Comments
 (0)