Skip to content

Commit

Permalink
ci: convert to windows path when necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
tmfink committed Apr 19, 2024
1 parent f71cdd1 commit 615e2dd
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions capstone-rs/ci/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export RUST_BACKTRACE=1
SHOULD_FAIL=${SHOULD_FAIL:-} # Default to false
VALGRIND_TESTS=${VALGRIND_TESTS:-}
CARGO="${CARGO:-cargo}"
UNAME="$(uname)"

# Feature vars
if [ -n "${ALL_FEATURES:-}" ] && [ -n "${NO_DEFAULT_FEATURES:-}" ]; then
Expand Down Expand Up @@ -66,13 +67,21 @@ echo "Running as USER=$USER"
echo "Test should $EXPECTED_RESULT"

if ! [ "${OS_NAME:-}" ]; then
case "$(uname)" in
case "${UNAME}" in
CYGWIN*|MINGW*|MSYS_NT*) OS_NAME=windows ;;
Linux) OS_NAME=linux ;;
Darwin) OS_NAME=osx ;;
FreeBSD) OS_NAME=freebsd ;;
esac
fi

true_path() {
case "${OS_NAME}" in
windows) cygpath -m "$@" ;;
*) echo "$@" ;;
esac
}

# Usage: SHOULD_FAIL [ARG1 [ARG2 [...]]]
expect_exit_status() {
local SHOULD_FAIL="$1"
Expand Down Expand Up @@ -216,7 +225,7 @@ test_rust_file() {
tmp_dir="$(mktemp -d /tmp/rust.testdir.XXXXXXXXXX)"
[ -d "$tmp_dir" ] || Error "Could not make temp dir"

capstone_dir="$(pwd)"
capstone_dir="$(true_path "$(pwd)")"
cd "$tmp_dir"
${CARGO} new --bin test_project -v
cd test_project
Expand Down Expand Up @@ -293,8 +302,12 @@ run_tests() {

cargo_update() {
if [ -z "${SKIP_CARGO_UPDATE:-}" ]; then
echo "Updating dependencies in Cargo.lock"
${CARGO} update
if [[ -n "${CI:-}" ]]; then
echo "Updating dependencies in Cargo.lock"
${CARGO} update
else
echo "Skipping 'cargo update' since we are not in CI"
fi
else
echo "Skipping 'cargo update' since SKIP_CARGO_UPDATE is set"
fi
Expand Down

0 comments on commit 615e2dd

Please sign in to comment.