summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--kleaf/tests/integration_test/BUILD.bazel13
-rw-r--r--kleaf/tests/integration_test/integration_test.py5
2 files changed, 15 insertions, 3 deletions
diff --git a/kleaf/tests/integration_test/BUILD.bazel b/kleaf/tests/integration_test/BUILD.bazel
index d8824c9..f196067 100644
--- a/kleaf/tests/integration_test/BUILD.bazel
+++ b/kleaf/tests/integration_test/BUILD.bazel
@@ -13,6 +13,7 @@
# limitations under the License.
load("@bazel_skylib//rules:common_settings.bzl", "string_flag")
+load("//build/kernel/kleaf/tests:hermetic_test.bzl", "hermetic_test_binary")
load("//build/kernel/kleaf/tests/utils:write_flag.bzl", "write_flag")
# tools/bazel run //build/kernel/kleaf/tests/integration_test
@@ -25,9 +26,19 @@ load("//build/kernel/kleaf/tests/utils:write_flag.bzl", "write_flag")
# - The test involves running `tools/bazel clean` in between. If this were executed
# with `tools/bazel test`, the directory structure in output_base would be broken
# before results are reported back to bazel.
-py_binary(
+hermetic_test_binary(
name = "integration_test",
+ actual = ":integration_test_internal",
+ # Preserve host PATH so:
+ # - The test can use `git`
+ # - The bazel wrapper can use `repo` when not running on CI
+ append_host_path = True,
+)
+
+py_binary(
+ name = "integration_test_internal",
srcs = ["integration_test.py"],
+ main = "integration_test.py",
deps = [
"//build/kernel/kleaf:wrapper",
"//build/kernel/kleaf/analysis:inputs",
diff --git a/kleaf/tests/integration_test/integration_test.py b/kleaf/tests/integration_test/integration_test.py
index 8676628..e7e1b2c 100644
--- a/kleaf/tests/integration_test/integration_test.py
+++ b/kleaf/tests/integration_test/integration_test.py
@@ -192,7 +192,8 @@ class KleafIntegrationTestBase(unittest.TestCase):
def setUp(self) -> None:
self.assertTrue(os.environ.get("BUILD_WORKSPACE_DIRECTORY"),
- "BUILD_WORKSPACE_DIRECTORY is not set")
+ "BUILD_WORKSPACE_DIRECTORY is not set. " +
+ "Did you use `tools/bazel test` instead of `tools/bazel run`?")
os.chdir(os.environ["BUILD_WORKSPACE_DIRECTORY"])
sys.stderr.write(
f"BUILD_WORKSPACE_DIRECTORY={os.environ['BUILD_WORKSPACE_DIRECTORY']}\n"
@@ -674,7 +675,7 @@ class ScmversionIntegrationTest(KleafIntegrationTestBase):
def setUp(self) -> None:
super().setUp()
- self.strings = "bazel-bin/build/kernel/hermetic-tools/llvm-strings"
+ self.strings = shutil.which("llvm-strings")
self.uname_pattern_prefix = re.compile(
r"^Linux version [0-9]+[.][0-9]+[.][0-9]+(\S*)")