diff options
author | Kevin Dagostino <kevindagostino@google.com> | 2023-03-31 09:54:44 +0000 |
---|---|---|
committer | Kevin Dagostino <kevindagostino@google.com> | 2023-03-31 15:33:05 +0000 |
commit | 14d2c48e62558cb3b68c19b45cb1f47394baf8e1 (patch) | |
tree | e0eeabf096a0ba1868333c0d49b23a429b9c7f9c | |
parent | 32142185cbf1dea92a7ff17f580f4632fac2575a (diff) | |
download | bazel-14d2c48e62558cb3b68c19b45cb1f47394baf8e1.tar.gz |
Fix missing tradefed dependencies in tradefed rule
Symlinks have been added so that libatest-tradefed.jar and libbazel-result-reporter.jar and other dependencies are now discoverable by tradefed.
Bug: 276390110
Test: b test //packages/modules/adb:adbd_test --config=android --//build/bazel/rules/tradefed:runmode=host_driven_test
Change-Id: Ie671059b1d119ddf53f8fe1cf8dee020ff522b36
-rw-r--r-- | rules/tradefed/tradefed.bzl | 20 | ||||
-rw-r--r-- | rules/tradefed/tradefed.sh.tpl | 5 | ||||
-rw-r--r-- | rules/tradefed/tradefed_test.bzl | 13 |
3 files changed, 20 insertions, 18 deletions
diff --git a/rules/tradefed/tradefed.bzl b/rules/tradefed/tradefed.bzl index 7694d672..64b4469d 100644 --- a/rules/tradefed/tradefed.bzl +++ b/rules/tradefed/tradefed.bzl @@ -132,21 +132,22 @@ def _tradefed_test_impl(ctx): ) targets.append(out) + # Symlink tradefed dependencies. + for f in ctx.files._tradefed_dependencies: + out = ctx.actions.declare_file(f.basename) + ctx.actions.symlink( + output = out, + target_file = f, + ) + targets.append(out) + # Gather runfiles. runfiles = ctx.runfiles() runfiles = runfiles.merge_all([ ctx.attr.test.default_runfiles, - ctx.runfiles(files = ctx.files._tradefed_dependencies + targets + [test_config, report_config]), + ctx.runfiles(files = targets + [test_config, report_config]), ]) - # Gather directories of runfiles to put on the PATH. - dependency_paths = {} - for f in runfiles.files.to_list(): - dependency_paths[f.dirname] = True - for f in runfiles.symlinks.to_list(): - dependency_paths[f.dirname] = True - path_additions = ":".join(dependency_paths.keys()) - # Generate script to run tradefed. script = ctx.actions.declare_file("tradefed_test_%s.sh" % ctx.label.name) ctx.actions.expand_template( @@ -155,7 +156,6 @@ def _tradefed_test_impl(ctx): is_executable = True, substitutions = { "{MODULE}": ctx.attr.test_identifier, - "{PATH_ADDITIONS}": path_additions, }, ) diff --git a/rules/tradefed/tradefed.sh.tpl b/rules/tradefed/tradefed.sh.tpl index b2937483..13d4c606 100644 --- a/rules/tradefed/tradefed.sh.tpl +++ b/rules/tradefed/tradefed.sh.tpl @@ -5,11 +5,6 @@ TEST_PATH="${TEST_SRCDIR}" SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) PATH_ADDITIONS="{PATH_ADDITIONS}" -# Add tradefed dependencies to PATH -for dep in ${PATH_ADDITIONS//:/ }; do - export PATH="${TEST_SRCDIR}/${TEST_WORKSPACE}/$dep:${PATH}" -done - export PATH="$SCRIPT_DIR:${PATH}" # Prepend the REMOTE_JAVA_HOME environment variable to the path to ensure # that all Java invocations throughout the test execution flow use the same diff --git a/rules/tradefed/tradefed_test.bzl b/rules/tradefed/tradefed_test.bzl index 1953a2e2..32a5afcc 100644 --- a/rules/tradefed/tradefed_test.bzl +++ b/rules/tradefed/tradefed_test.bzl @@ -20,6 +20,13 @@ load( ) load(":tradefed.bzl", "tradefed_device_test", "tradefed_host_driven_test") +tradefed_dependencies = [ + "atest_tradefed.sh", + "libatest-tradefed.jar", + "libbazel-result-reporter.jar", + "tradefed.jar", +] + def _test_tradefed_config_generation_impl(ctx): env = analysistest.begin(ctx) actions = analysistest.target_actions(env) @@ -72,7 +79,7 @@ def tradefed_cc_outputs(): "tradefed_test_" + name + ".sh", "result-reporters.xml", target + ".config", - ], + ] + tradefed_dependencies, target_compatible_with = ["//build/bazel/platforms/os:linux"], ) return name + "_test" @@ -102,7 +109,7 @@ def tradefed_cc_host_outputs(): "tradefed_test_" + name + ".sh", "result-reporters.xml", target + ".config", - ], + ] + tradefed_dependencies, target_compatible_with = ["//build/bazel/platforms/os:linux"], ) return name + "_test" @@ -136,7 +143,7 @@ def tradefed_cc_host_outputs_generate_test_config(): "tradefed_test_" + name + ".sh", "result-reporters.xml", target + ".config", - ], + ] + tradefed_dependencies, target_compatible_with = ["//build/bazel/platforms/os:linux"], ) return name + "_test" |