Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make inferred workspace dir consistent with actual one in builds #129

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bazelisk.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
44 changes: 44 additions & 0 deletions bazelisk_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down