bazelbuild / bazel

a fast, scalable, multi-language and extensible build system
https://bazel.build
Apache License 2.0
23.25k stars 4.08k forks source link

Hermeticity violated in tools/test/test-setup.sh #24369

Open mering opened 14 hours ago

mering commented 14 hours ago

Description of the bug:

When writing files to $TEST_UNDECLARED_OUTPUTS_DIR, test-setup.sh requires the file and zip tools to be installed on the RBE runners itself. Since 7a183118187a8a799f2c23d935d3330e33527604 the build fails if these tools are not available. This violates hermeticity. @bazel_tools should provide all necessary functionality it needs in a hermetic way.

Which category does this issue belong to?

No response

What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

Use an sh_test with the following script:

#!/bin/bash
touch "${TEST_UNDECLARED_OUTPUTS_DIR}/undeclared-output.txt"

and run it with Bazel 7.4+ on an RBE runner with out file and zip tools available (for example a plain debian:12 image from Docker Hub).

Which operating system are you running Bazel on?

Linux

What is the output of bazel info release?

7.4.1

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

No response

What's the output of git remote get-url origin; git rev-parse HEAD ?

No response

If this is a regression, please try to identify the Bazel commit where the bug was introduced with bazelisk --bisect.

The functionality never worked and starting from 7a183118187a8a799f2c23d935d3330e33527604 (@tjgq FYI) it is a hard error.

Have you found anything relevant by searching the web?

No response

Any other information, logs, or outputs that you want to share?

No response

benjaminp commented 14 hours ago

24056 #13230

tjgq commented 14 hours ago

I acknowledge that the use of zip in test-setup.sh is non-hermetic, but the non-hermeticity was not introduced by https://github.com/bazelbuild/bazel/commit/7a183118187a8a799f2c23d935d3330e33527604; the test wrapper has always expected certain shell utilities to be provided by the execution environment. The only thing that changed is that we used to fail silently (and produce an incorrect result!) when zip was unavailable, and we fail loudly now.

Are you able to use --nozip_undeclared_test_outputs instead? (This will also become the default in Bazel 8.)

mering commented 14 hours ago

@tjgq Thanks for your quick reply. With this option the test indeed doesn't fail any more but still prints the following warning:

external/bazel_tools/tools/test/test-setup.sh: line 396: file: command not found