Skip to content

Commit

Permalink
In reproducibility test, use disposable output_base
Browse files Browse the repository at this point in the history
  • Loading branch information
Siddhartha Bagaria committed Jul 1, 2018
1 parent 6563612 commit fdf2ed1
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions tests/core/reproducibility/test.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,35 @@
#!/bin/bash
set -eu -o pipefail

BAZEL_OPTS=(
"--bazelrc=/dev/null" # Disable any user specified remote/disk caching
)

function run_bazel() {
bazel "${BAZEL_OPTS[@]}" clean --expunge
bazel "${BAZEL_OPTS[@]}" build //tests/core/go_binary:all //tests/core/cgo:opts_test
local output_base
local bazel_opts
local build_opts

output_base=$(mktemp -d)
bazel_opts=(
"--bazelrc=/dev/null" # Disable any user specified remote/disk caching.
"--output_base=${output_base}" # Use a disposable output_base.
)
build_opts=()

if [[ $(uname -s) == "Linux" ]]; then
# Use shared memory sandbox for faster runs.
build_opts+=("--experimental_sandbox_base=/dev/shm")
fi

bazel "${bazel_opts[@]}" build "${build_opts[@]}" \
//tests/core/go_binary:all \
//tests/core/cgo:opts_test

{
find bazel-out/ -name '*.a' | sort | uniq | grep stdlib | xargs shasum
find bazel-bin/tests/core/go_binary -name 'custom_bin' -exec shasum {} \;
find bazel-bin/tests/core/cgo -name 'opts_test' -exec shasum {} \;
} > "$1"

chmod -R u+w "${output_base}" # Give write permissions so we can use `rm -rf`.
rm -rf "${output_base}"
}

FILE1=$(mktemp)
Expand All @@ -26,6 +43,7 @@ run_bazel "${FILE2}"

echo Diffing runs
diff "${FILE1}" "${FILE2}"
echo Builds are identical!

echo Removing files
rm "${FILE1}" "${FILE2}"

0 comments on commit fdf2ed1

Please sign in to comment.