From 3cde6867f6a4952b361eb50d10ad2b4448bd5355 Mon Sep 17 00:00:00 2001 From: Geoff Mishkin Date: Thu, 2 Apr 2020 17:48:36 -0400 Subject: [PATCH 1/2] make inferred workspace dir consistent with actual one in builds --- bazelisk.py | 2 +- bazelisk_test.sh | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) 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..4c14c578 100755 --- a/bazelisk_test.sh +++ b/bazelisk_test.sh @@ -184,6 +184,42 @@ 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 + + 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 +266,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 From 6670ed3b60787b4493d01cb1887cbdc7911a6cf1 Mon Sep 17 00:00:00 2001 From: Geoff Mishkin Date: Fri, 3 Apr 2020 12:07:17 -0400 Subject: [PATCH 2/2] i _think_ this is what itd be on windows? --- bazelisk_test.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bazelisk_test.sh b/bazelisk_test.sh index 4c14c578..95e2f64f 100755 --- a/bazelisk_test.sh +++ b/bazelisk_test.sh @@ -207,6 +207,10 @@ $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