Skip to content

Commit

Permalink
remove hardcoded target dir from justfile
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
niklaswimmer committed Jul 29, 2023
1 parent 72f3027 commit dfe869c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 10 deletions.
6 changes: 5 additions & 1 deletion cargo-smart-release/tests/journey.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ set -eu
exe=${1:?First argument must be the executable to test}

root="$(cd "${0%/*}" && pwd)"
exe="${root}/../$exe"

# if exe path is relative eval it from the parent of this script's location
if [[ $exe != /* ]]; then
exe="${root}/../$exe"
fi

# shellcheck disable=1090
source "$root/utilities.sh"
Expand Down
17 changes: 11 additions & 6 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -174,36 +174,41 @@ unit-tests:
unit-tests-flaky:
cargo test -p gix --features async-network-client-async-std

jtt := "target/debug/jtt"
target_dir := `cargo metadata --format-version 1 | jq -r .target_directory`
ein := target_dir / "debug/ein"
gix := target_dir / "debug/gix"
jtt := target_dir / "debug/jtt"

# run journey tests (max)
journey-tests:
cargo build
cargo build -p gix-testtools --bin jtt
./tests/journey.sh target/debug/ein target/debug/gix {{ jtt }} max
./tests/journey.sh {{ ein }} {{ gix }} {{ jtt }} max

# run journey tests (max-pure)
journey-tests-pure:
cargo build --no-default-features --features max-pure
cargo build -p gix-testtools --bin jtt
./tests/journey.sh target/debug/ein target/debug/gix {{ jtt }} max-pure
./tests/journey.sh {{ ein }} {{ gix }} {{ jtt }} max-pure

# run journey tests (small)
journey-tests-small:
cargo build --no-default-features --features small
cargo build -p gix-testtools
./tests/journey.sh target/debug/ein target/debug/gix {{ jtt }} small
./tests/journey.sh {{ ein }} {{ gix }} {{ jtt }} small

# run journey tests (lean-async)
journey-tests-async:
cargo build --no-default-features --features lean-async
cargo build -p gix-testtools
./tests/journey.sh target/debug/ein target/debug/gix {{ jtt }} async
./tests/journey.sh {{ ein }} {{ gix }} {{ jtt }} async

cargo-smart-release := `cargo metadata --manifest-path ./cargo-smart-release/Cargo.toml --format-version 1 | jq -r .target_directory` / "debug/cargo-smart-release"

# run journey tests (cargo-smart-release)
journey-tests-smart-release:
cd cargo-smart-release && cargo build --bin cargo-smart-release
cd cargo-smart-release && ./tests/journey.sh ../cargo-smart-release/target/debug/cargo-smart-release
cd cargo-smart-release && ./tests/journey.sh {{ cargo-smart-release }}

# Run cargo-diet on all crates to see that they are still in bound
check-size:
Expand Down
14 changes: 11 additions & 3 deletions tests/journey.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,17 @@ jtt=${3:?Third argument the journey test tool}
kind=${4:?Fourth argument must an indicator of the kind of binary under test}

root="$(cd "${0%/*}" && pwd)"
exe="${root}/../$exe"
exe_plumbing="${root}/../$exe_plumbing"
jtt="${root}/../$jtt"

# if relative paths are given eval them from the parent of this script's location
if [[ $exe != /* ]]; then
exe="${root}/../$exe"
fi
if [[ $exe_plumbing != /* ]]; then
exe_plumbing="${root}/../$exe_plumbing"
fi
if [[ $jtt != /* ]]; then
jtt="${root}/../$jtt"
fi

# shellcheck disable=1090
source "$root/utilities.sh"
Expand Down

0 comments on commit dfe869c

Please sign in to comment.