From d1fe2f6b09ab86d2e6d17c042ba52b383cd547ae Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Fri, 8 Sep 2023 21:50:32 -0400 Subject: [PATCH] Update the rest of the scripts to work with relative paths. --- scripts/callgrind.bash | 8 ++++---- scripts/perf.bash | 8 +++----- scripts/run_docker_integration_test.bash | 3 +-- scripts/run_integration_test.bash | 3 +-- scripts/time_parse.bash | 6 ++---- 5 files changed, 11 insertions(+), 17 deletions(-) diff --git a/scripts/callgrind.bash b/scripts/callgrind.bash index 3bc909c4..9f13c7b2 100755 --- a/scripts/callgrind.bash +++ b/scripts/callgrind.bash @@ -4,10 +4,10 @@ set -euo pipefail IFS=$'\n\t' DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -cd "$DIR/../" -RUSTFLAGS="-C opt-level=0" cargo build --no-default-features -valgrind --tool=callgrind --callgrind-out-file=callgrind.out target/debug/parse "${@}" + +(cd "$DIR/../" && RUSTFLAGS="-C opt-level=0" cargo build --no-default-features) +valgrind --tool=callgrind --callgrind-out-file="$DIR/../callgrind.out" "$DIR/../target/debug/parse" "${@}" echo "You probably want to run:" -echo "callgrind_annotate --auto=yes callgrind.out" +echo "callgrind_annotate --auto=yes '$DIR/../callgrind.out'" diff --git a/scripts/perf.bash b/scripts/perf.bash index f40e58be..aa7ae329 100755 --- a/scripts/perf.bash +++ b/scripts/perf.bash @@ -6,8 +6,6 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" : ${PROFILE:="perf"} -cd "$DIR/../" - function main { local additional_flags=() if [ "$PROFILE" = "dev" ] || [ "$PROFILE" = "debug" ]; then @@ -15,12 +13,12 @@ function main { else additional_flags+=(--profile "$PROFILE") fi - cargo build --no-default-features "${additional_flags[@]}" - perf record --freq=2000 --call-graph dwarf --output=perf.data target/${PROFILE}/parse "${@}" + (cd "$DIR/../" && cargo build --no-default-features "${additional_flags[@]}") + perf record --freq=2000 --call-graph dwarf --output="$DIR/../perf.data" "$DIR/../target/${PROFILE}/parse" "${@}" # Convert to a format firefox will read # flags to consider --show-info - perf script -F +pid --input perf.data > perf.firefox + perf script -F +pid --input "$DIR/../perf.data" > "$DIR/../perf.firefox" echo "You probably want to go to https://profiler.firefox.com/" echo "Either that or run hotspot" diff --git a/scripts/run_docker_integration_test.bash b/scripts/run_docker_integration_test.bash index 5ba5a373..bcf2646d 100755 --- a/scripts/run_docker_integration_test.bash +++ b/scripts/run_docker_integration_test.bash @@ -6,7 +6,6 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" : ${NO_COLOR:=""} # Set to anything to disable color output -cd "$DIR/../" REALPATH=$(command -v uu-realpath || command -v realpath) MAKE=$(command -v gmake || command -v make) @@ -56,7 +55,7 @@ cargo test --no-default-features --features compare --no-fail-fast --lib --test EOF ) - docker run "${additional_flags[@]}" --init --rm --read-only --mount type=tmpfs,destination=/tmp -v "$($REALPATH ./):/source:ro" --mount source=cargo-cache,target=/usr/local/cargo/registry --mount source=rust-cache,target=/target --env CARGO_TARGET_DIR=/target -w /source --entrypoint "" organic-test sh -c "$init_script" + docker run "${additional_flags[@]}" --init --rm --read-only --mount type=tmpfs,destination=/tmp -v "$($REALPATH "$DIR/../"):/source:ro" --mount source=cargo-cache,target=/usr/local/cargo/registry --mount source=rust-cache,target=/target --env CARGO_TARGET_DIR=/target -w /source --entrypoint "" organic-test sh -c "$init_script" } diff --git a/scripts/run_integration_test.bash b/scripts/run_integration_test.bash index 32da81da..095bee99 100755 --- a/scripts/run_integration_test.bash +++ b/scripts/run_integration_test.bash @@ -4,7 +4,6 @@ set -euo pipefail IFS=$'\n\t' DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -cd "$DIR/../" REALPATH=$(command -v uu-realpath || command -v realpath) function main { @@ -12,7 +11,7 @@ function main { local test while read test; do - cargo test --no-default-features --features compare --no-fail-fast --test test_loader "$test" -- --show-output + (cd "$DIR/../" && cargo test --no-default-features --features compare --no-fail-fast --test test_loader "$test" -- --show-output) done<<<"$test_names" } diff --git a/scripts/time_parse.bash b/scripts/time_parse.bash index 817bada2..6409f3f3 100755 --- a/scripts/time_parse.bash +++ b/scripts/time_parse.bash @@ -7,8 +7,6 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" : ${PROFILE:="release-lto"} -cd "$DIR/../" - function main { local additional_flags=() if [ "$PROFILE" = "dev" ] || [ "$PROFILE" = "debug" ]; then @@ -16,8 +14,8 @@ function main { else additional_flags+=(--profile "$PROFILE") fi - cargo build --no-default-features "${additional_flags[@]}" - time ./target/${PROFILE}/parse "${@}" + (cd "$DIR/../" && cargo build --no-default-features "${additional_flags[@]}") + time "$DIR/../target/${PROFILE}/parse" "${@}" } main "${@}"