diff --git a/bazelisk.py b/bazelisk.py index 6bfd8376..f77b35f6 100755 --- a/bazelisk.py +++ b/bazelisk.py @@ -53,7 +53,7 @@ SUPPORTED_PLATFORMS = {"linux": "ubuntu1404", "windows": "windows", "darwin": "macos"} -TOOLS_BAZEL_PATH = "./tools/bazel" +TOOLS_BAZEL_PATH = "tools/bazel" BAZEL_REAL = "BAZEL_REAL" diff --git a/bazelisk_test.sh b/bazelisk_test.sh index 19efc7dd..95e2f64f 100755 --- a/bazelisk_test.sh +++ b/bazelisk_test.sh @@ -184,6 +184,46 @@ EOF (echo "FAIL: Expected to find 'BAZELISK_SKIP_WRAPPER=true' in the output of 'bazelisk version'"; exit 1) } +function test_delegate_to_wrapper_matching_workspace_dir() { + setup + + cat > print_workspace_dir.sh <<'EOF' +echo "$BUILD_WORKSPACE_DIRECTORY" +EOF + chmod +x print_workspace_dir.sh + + cat >> BUILD <<'EOF' +sh_binary( + name = "print_workspace_dir", + srcs = ["print_workspace_dir.sh"], +) +EOF + + mkdir tools + cat > tools/bazel <<'EOF' +#!/usr/bin/env bash +echo "$(dirname "$(dirname "${BASH_SOURCE[0]}")")" +$BAZEL_REAL "${@:1}" +EOF + chmod +x tools/bazel + + cat > tools/bazel.bat <<'EOF' +python %~dp0\bazel %* +EOF + + BAZELISK_HOME="$BAZELISK_HOME" \ + bazelisk run :print_workspace_dir | tee log + + last_line="" + tail -n +2 log | while read -r line; do + if [ -z "$last_line" ]; then + last_line="$line" + elif [ "$line" != "$last_line" ]; then + echo "FAIL: Expected workspace directories to match"; exit 1 + fi + done +} + function test_skip_wrapper() { setup @@ -230,6 +270,10 @@ echo "# test_bazel_last_downstream_green" test_bazel_last_downstream_green echo +echo "# test_delegate_to_wrapper_matching_workspace_dir" +test_delegate_to_wrapper_matching_workspace_dir +echo + if [[ $BAZELISK_VERSION == "GO" ]]; then echo "# test_bazel_last_rc" test_bazel_last_rc