Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
5 changes: 2 additions & 3 deletions python/private/stage1_bootstrap_template.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ else
echo "$RUNFILES_DIR"
return 0
elif [[ "${RUNFILES_MANIFEST_FILE:-}" = *".runfiles_manifest" ]]; then
echo "${RUNFILES_MANIFEST_FILE%%.runfiles_manifest}"
echo "${RUNFILES_MANIFEST_FILE%%.runfiles_manifest}.runfiles"
return 0
elif [[ "${RUNFILES_MANIFEST_FILE:-}" = *".runfiles/MANIFEST" ]]; then
echo "${RUNFILES_MANIFEST_FILE%%.runfiles/MANIFEST}"
echo "${RUNFILES_MANIFEST_FILE%%.runfiles/MANIFEST}.runfiles"
return 0
fi

Expand All @@ -57,7 +57,6 @@ else
if [[ "$stub_filename" != /* ]]; then
stub_filename="$PWD/$stub_filename"
fi

while true; do
module_space="${stub_filename}.runfiles"
if [[ -d "$module_space" ]]; then
Expand Down
51 changes: 41 additions & 10 deletions tests/bootstrap_impls/run_binary_zip_no_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,46 @@ if [[ -z "$bin" ]]; then
echo "Unable to locate test binary: $BIN_RLOCATION"
exit 1
fi
actual=$($bin 2>&1)

# How we detect if a zip file was executed from depends on which bootstrap
# is used.
# bootstrap_impl=script outputs RULES_PYTHON_ZIP_DIR=<somepath>
# bootstrap_impl=system_python outputs file:.*Bazel.runfiles
expected_pattern="Hello"
if ! (echo "$actual" | grep "$expected_pattern" ) >/dev/null; then
echo "expected output to match: $expected_pattern"
echo "but got:\n$actual"

function test_invocation() {
actual=$($bin)
# How we detect if a zip file was executed from depends on which bootstrap
# is used.
# bootstrap_impl=script outputs RULES_PYTHON_ZIP_DIR=<somepath>
# bootstrap_impl=system_python outputs file:.*Bazel.runfiles
expected_pattern="Hello"
if ! (echo "$actual" | grep "$expected_pattern" ) >/dev/null; then
echo "Test case failed: $1"
echo "expected output to match: $expected_pattern"
echo "but got:\n$actual"
exit 1
fi
}

# Test invocation with RUNFILES_DIR set
unset RUNFILES_MANIFEST_FILE
if [[ ! -e "$RUNFILES_DIR" ]]; then
echo "Runfiles doesn't exist: $RUNFILES_DIR"
exit 1
fi
test_invocation "using RUNFILES_DIR"


orig_runfiles_dir="$RUNFILES_DIR"
unset RUNFILES_DIR

# Test invocation using manifest within runfiles directory (output manifest)
# NOTE: this file may not actually exist in our test, but that's OK; the
# bootstrap just uses the path to find the runfiles directory.
export RUNFILES_MANIFEST_FILE="$orig_runfiles_dir/MANIFEST"
test_invocation "using RUNFILES_MANIFEST_FILE with output manifest"

# Test invocation using manifest outside runfiles (input manifest)
# NOTE: this file may not actually exist in our test, but that's OK; the
# bootstrap just uses the path to find the runfiles directory.
export RUNFILES_MANIFEST_FILE="${orig_runfiles_dir%%.runfiles}.runfiles_manifest"
test_invocation "using RUNFILES_MANIFEST_FILE with input manifest"

# Test invocation without any runfiles env vars set
unset RUNFILES_MANIFEST_FILE
test_invocation "using no runfiles env vars"