summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYifan Hong <elsk@google.com>2024-05-07 16:10:29 -0700
committerTreehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com>2024-05-13 23:44:45 +0000
commit5dae65a58d7a523c89adb7a92caf4a109e2bfc55 (patch)
tree75cf11b9887806f20c0822a92f7dec3d660a9715
parent98982ebdcf4c5b6af17643c1d9775f3d718054df (diff)
downloadbuild-main.tar.gz
kleaf: Wrap integration_test with hermetic_testHEADmastermain
so it can use toys from hermetic-tools. In this change, hermetic_tools (for tests) run_additional_setup is used before running integration test so that git / repo still works in the integration test. Bug: 338263410 Change-Id: I2941a08d97e71282027654ccaf3e0c6eb88ee894
-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*)")