|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +set -o errexit -o pipefail -o nounset |
| 4 | + |
| 5 | +OS="$(uname | tr '[:upper:]' '[:lower:]')" |
| 6 | +ARCH="$(arch)" |
| 7 | +ALLOWED="rules_py_tools.${OS}_${ARCH}" |
| 8 | +if [ "$ARCH" == "x86_64" ]; then |
| 9 | + ALLOWED="rules_py_tools.${OS}_amd64" |
| 10 | +fi |
| 11 | + |
| 12 | +# This test references pre-built artifacts from a prior release. |
| 13 | +# Will need to bump this version in the future when there are breaking changes. |
| 14 | +export RULES_PY_RELEASE_VERSION=0.7.0 |
| 15 | + |
| 16 | +############# |
| 17 | +# Test bzlmod |
| 18 | +( |
| 19 | + cd ../.. |
| 20 | + patch -p1 < .bcr/patches/*.patch |
| 21 | +) |
| 22 | +OUTPUT_BASE=$(mktemp -d) |
| 23 | +output=$(bazel "--output_base=$OUTPUT_BASE" run --enable_bzlmod //:main) |
| 24 | +if [[ "$output" != "hello world" ]]; then |
| 25 | + >&2 echo "ERROR: bazel command did not produce expected output" |
| 26 | + exit 1 |
| 27 | +fi |
| 28 | +externals=$(ls $OUTPUT_BASE/external) |
| 29 | + |
| 30 | +if echo "$externals" | grep -v "${ALLOWED}" | grep -v ".marker" | grep rules_py_tools. |
| 31 | +then |
| 32 | + >&2 echo "ERROR: rules_py binaries were fetched for platform other than ${ALLOWED}" |
| 33 | + exit 1 |
| 34 | +fi |
| 35 | +if echo "$externals" | grep rust |
| 36 | +then |
| 37 | + >&2 echo "ERROR: we fetched a rust repository" |
| 38 | + exit 1 |
| 39 | +fi |
| 40 | + |
| 41 | +############# |
| 42 | +# Test WORKSPACE |
| 43 | +OUTPUT_BASE=$(mktemp -d) |
| 44 | +output=$(bazel "--output_base=$OUTPUT_BASE" run --noenable_bzlmod //:main) |
| 45 | +if [[ "$output" != "hello world" ]]; then |
| 46 | + >&2 echo "ERROR: bazel command did not produce expected output" |
| 47 | + exit 1 |
| 48 | +fi |
| 49 | + |
| 50 | +externals=$(ls $OUTPUT_BASE/external) |
| 51 | + |
| 52 | +if echo "$externals" | grep -v "${ALLOWED}" | grep -v ".marker" | grep rules_py_tools. |
| 53 | +then |
| 54 | + >&2 echo "ERROR: rules_py binaries were fetched for platform other than ${ALLOWED}" |
| 55 | + exit 1 |
| 56 | +fi |
| 57 | +if echo "$externals" | grep rust |
| 58 | +then |
| 59 | + >&2 echo "ERROR: we fetched a rust repository" |
| 60 | + exit 1 |
| 61 | +fi |
0 commit comments