forked from bazel-contrib/rules_python
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsystem_python_zipapp_external_bootstrap_test.sh
More file actions
executable file
·50 lines (40 loc) · 1.72 KB
/
system_python_zipapp_external_bootstrap_test.sh
File metadata and controls
executable file
·50 lines (40 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env bash
set -xeuo pipefail
# This test expects ZIPAPP env var to point to the zipapp file.
if [[ -z "${ZIPAPP:-}" ]]; then
echo "ZIPAPP env var not set"
exit 1
fi
# On Windows, the executable file is an exe, and the .zip is a sibling
# output.
ZIPAPP="${ZIPAPP/.exe/.zip}"
export RULES_PYTHON_BOOTSTRAP_VERBOSE=1
# We're testing the invocation of `__main__.py`, so we have to
# manually pass the zipapp to python.
echo "Running zipapp using an automatic temp directory..."
"$PYTHON" "$ZIPAPP"
echo "Running zipapp with extract root set..."
export RULES_PYTHON_EXTRACT_ROOT="${TEST_TMPDIR:-/tmp}/extract_root_test"
"$PYTHON" "$ZIPAPP"
# Verify that the directory was created
if [[ ! -d "$RULES_PYTHON_EXTRACT_ROOT" ]]; then
echo "Error: Extract root directory $RULES_PYTHON_EXTRACT_ROOT was not created!"
exit 1
fi
# The extract dir is _main/tests/py_zipapp/system_python_zipapp
# The new structure should be $RULES_PYTHON_EXTRACT_ROOT/_main/tests/py_zipapp/system_python_zipapp/<hash>/runfiles
# We check that there is a subdirectory under the expected extract dir.
EXTRACT_DIR="_main/tests/py_zipapp/system_python_zipapp"
if [[ ! -d "$RULES_PYTHON_EXTRACT_ROOT/$EXTRACT_DIR" ]]; then
echo "Error: Extract directory $RULES_PYTHON_EXTRACT_ROOT/$EXTRACT_DIR was not created!"
exit 1
fi
# Check for the extra hash component.
# We use glob expansion to check for the expected depth.
# Note: [ -d ... ] expands globs, while [[ -d ... ]] does not.
if [ ! -d "$RULES_PYTHON_EXTRACT_ROOT/$EXTRACT_DIR"/*/runfiles ]; then
echo "Error: Could not find 'runfiles' directory at expected depth $RULES_PYTHON_EXTRACT_ROOT/$EXTRACT_DIR/*/runfiles"
exit 1
fi
echo "Running zipapp with extract root set a second time..."
"$PYTHON" "$ZIPAPP"