Skip to content

Commit dfe869c

Browse files
committed
remove hardcoded target dir from justfile
The hardcoded `./target` path fails for environments where Cargo is configured to use a different target directory (for example via `CARGO_TARGET_DIR`). Since we are now passing absolute paths to the `journey.sh` scripts the previous behavior of manipulating the path needed to be removed. Because some personal scripts may have depended on that functionality, I opted to conditionally apply the manipulations if the given paths are found to be relative.
1 parent 72f3027 commit dfe869c

File tree

3 files changed

+27
-10
lines changed

3 files changed

+27
-10
lines changed

cargo-smart-release/tests/journey.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ set -eu
44
exe=${1:?First argument must be the executable to test}
55

66
root="$(cd "${0%/*}" && pwd)"
7-
exe="${root}/../$exe"
7+
8+
# if exe path is relative eval it from the parent of this script's location
9+
if [[ $exe != /* ]]; then
10+
exe="${root}/../$exe"
11+
fi
812

913
# shellcheck disable=1090
1014
source "$root/utilities.sh"

justfile

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -174,36 +174,41 @@ unit-tests:
174174
unit-tests-flaky:
175175
cargo test -p gix --features async-network-client-async-std
176176

177-
jtt := "target/debug/jtt"
177+
target_dir := `cargo metadata --format-version 1 | jq -r .target_directory`
178+
ein := target_dir / "debug/ein"
179+
gix := target_dir / "debug/gix"
180+
jtt := target_dir / "debug/jtt"
178181

179182
# run journey tests (max)
180183
journey-tests:
181184
cargo build
182185
cargo build -p gix-testtools --bin jtt
183-
./tests/journey.sh target/debug/ein target/debug/gix {{ jtt }} max
186+
./tests/journey.sh {{ ein }} {{ gix }} {{ jtt }} max
184187

185188
# run journey tests (max-pure)
186189
journey-tests-pure:
187190
cargo build --no-default-features --features max-pure
188191
cargo build -p gix-testtools --bin jtt
189-
./tests/journey.sh target/debug/ein target/debug/gix {{ jtt }} max-pure
192+
./tests/journey.sh {{ ein }} {{ gix }} {{ jtt }} max-pure
190193

191194
# run journey tests (small)
192195
journey-tests-small:
193196
cargo build --no-default-features --features small
194197
cargo build -p gix-testtools
195-
./tests/journey.sh target/debug/ein target/debug/gix {{ jtt }} small
198+
./tests/journey.sh {{ ein }} {{ gix }} {{ jtt }} small
196199

197200
# run journey tests (lean-async)
198201
journey-tests-async:
199202
cargo build --no-default-features --features lean-async
200203
cargo build -p gix-testtools
201-
./tests/journey.sh target/debug/ein target/debug/gix {{ jtt }} async
204+
./tests/journey.sh {{ ein }} {{ gix }} {{ jtt }} async
205+
206+
cargo-smart-release := `cargo metadata --manifest-path ./cargo-smart-release/Cargo.toml --format-version 1 | jq -r .target_directory` / "debug/cargo-smart-release"
202207

203208
# run journey tests (cargo-smart-release)
204209
journey-tests-smart-release:
205210
cd cargo-smart-release && cargo build --bin cargo-smart-release
206-
cd cargo-smart-release && ./tests/journey.sh ../cargo-smart-release/target/debug/cargo-smart-release
211+
cd cargo-smart-release && ./tests/journey.sh {{ cargo-smart-release }}
207212

208213
# Run cargo-diet on all crates to see that they are still in bound
209214
check-size:

tests/journey.sh

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,17 @@ jtt=${3:?Third argument the journey test tool}
77
kind=${4:?Fourth argument must an indicator of the kind of binary under test}
88

99
root="$(cd "${0%/*}" && pwd)"
10-
exe="${root}/../$exe"
11-
exe_plumbing="${root}/../$exe_plumbing"
12-
jtt="${root}/../$jtt"
10+
11+
# if relative paths are given eval them from the parent of this script's location
12+
if [[ $exe != /* ]]; then
13+
exe="${root}/../$exe"
14+
fi
15+
if [[ $exe_plumbing != /* ]]; then
16+
exe_plumbing="${root}/../$exe_plumbing"
17+
fi
18+
if [[ $jtt != /* ]]; then
19+
jtt="${root}/../$jtt"
20+
fi
1321

1422
# shellcheck disable=1090
1523
source "$root/utilities.sh"

0 commit comments

Comments
 (0)