Skip to content

Commit

Permalink
Add a test for bazel-distfile.tar.
Browse files Browse the repository at this point in the history
Also cleans up generation of bazel-distfile.tar to work on macOS.

Fixes bazelbuild#11741.

Closes bazelbuild#11743.

PiperOrigin-RevId: 320938268
  • Loading branch information
katre authored and copybara-github committed Jul 13, 2020
1 parent db3082d commit d8c8a2b
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 8 deletions.
14 changes: 12 additions & 2 deletions combine_distfiles_to_tar.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,15 @@ do
(cd "${PACKAGE_DIR}" && ${UNPACK} "${ARCHIVE}")
done

(cd "${PACKAGE_DIR}" && tar -c -f "${OUTPUT}" --group=0 --owner=0 \
$(find . -type f | sort))
ID_OPTS="--group=0 --owner=0"
if [ "$(uname -s)" == "Darwin" ]; then
ID_OPTS="--gid=0 --uid=0"
fi

(
cd "${PACKAGE_DIR}"
FILE_LIST="$(mktemp ${TMP_DIR%%/}/bazel-distfile-files.XXXXXXXX)"
trap "rm -fr \"${FILE_LIST}\"" EXIT
find . -type f | sort > "${FILE_LIST}"
tar -c -f "${OUTPUT}" ${ID_OPTS} -T "${FILE_LIST}"
)
21 changes: 21 additions & 0 deletions src/test/shell/bazel/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -1006,6 +1006,27 @@ sh_test(
tags = ["block-network"],
)

sh_test(
name = "bazel_bootstrap_distfile_tar_test",
timeout = "eternal",
srcs = ["bazel_bootstrap_distfile_test.sh"],
args = [
"$(location //:bazel-distfile-tar)",
"$(location //src:embedded_jdk_allmodules_cached)",
],
data = [
":test-deps",
"//:bazel-distfile-tar",
"//src:embedded_jdk_allmodules_cached",
"@bazel_tools//tools/bash/runfiles",
],
exec_compatible_with = ["//:highcpu_machine"],
tags = [
"block-network",
"no_windows",
],
)

sh_test(
name = "bazel_determinism_test",
timeout = "eternal",
Expand Down
34 changes: 28 additions & 6 deletions src/test/shell/bazel/bazel_bootstrap_distfile_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,34 @@ fi
function test_bootstrap() {
cd "$(mktemp -d ${TEST_TMPDIR}/bazelbootstrap.XXXXXXXX)"
export SOURCE_DATE_EPOCH=1501234567
unzip -q "${DISTFILE}"
if [[ $EMBEDDED_JDK == *.tar.gz ]]; then
tar xf $EMBEDDED_JDK
elif [[ $EMBEDDED_JDK == *.zip ]]; then
unzip -q $EMBEDDED_JDK
fi

case "${DISTFILE}" in
*.zip)
unzip -q "${DISTFILE}"
;;
*.tar)
tar xf "${DISTFILE}"
;;
*)
fail "Unknown distfile format: ${DISTFILE}"
;;
esac

case "${EMBEDDED_JDK}" in
*.zip)
unzip -q "$EMBEDDED_JDK"
;;
*.tar.gz)
tar zxf "$EMBEDDED_JDK"
;;
*.tar)
tar xf "$EMBEDDED_JDK"
;;
*)
fail "Unknown embedded JDK format: ${EMBEDDED_JDK}"
;;
esac

JAVABASE=$(echo reduced*)

env EXTRA_BAZEL_ARGS="--host_javabase=@local_jdk//:jdk" ./compile.sh \
Expand Down

0 comments on commit d8c8a2b

Please sign in to comment.