diff options
author | Googler <noreply@google.com> | 2018-05-07 09:46:46 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-05-07 09:48:19 -0700 |
commit | 0b7f9f8a7be0fbfe84baf8e4d1dc652f81e20073 (patch) | |
tree | 0ae6da41d10ad3cf838d576522ce1834a076b089 /src/test/py | |
parent | b5573a6df78527be0bb15da54df03f9981e1302d (diff) |
Add absolute path handling to Rlocation implementation used for remote execution on Windows from Java launcher.
Previously the test case would fail because it tried to run a path like this:
C:/temp/build-1dad9dd4-ee96-40c5-b551-c8ae12461e45/bazel-out/x64_windows-fastbuild/bin/foo/foo_test.exe.runfiles/C:/openjdk/bin/java.exe
Passing presubmit: https://buildkite.com/bazel/google-bazel-presubmit/builds/2558#b83dbc25-d9ad-4d49-8f78-cde9d6810741
RELNOTES: N/A
PiperOrigin-RevId: 195675424
Diffstat (limited to 'src/test/py')
-rw-r--r-- | src/test/py/bazel/windows_remote_test.py | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/test/py/bazel/windows_remote_test.py b/src/test/py/bazel/windows_remote_test.py index 0ec3fbdf06..fc9a03a139 100644 --- a/src/test/py/bazel/windows_remote_test.py +++ b/src/test/py/bazel/windows_remote_test.py @@ -163,6 +163,51 @@ class WindowsRemoteTest(test_base.TestBase): ['test', '--test_output=all', '//foo:foo_test']) self.AssertExitCode(exit_code, 0, stderr, stdout) + # Exercises absolute path handling in Rlocation. + # This depends on there being a Java installation to c:\openjdk. If you have + # it elsewhere, add --test_env=JAVA_HOME to your Bazel invocation to fix this + # test. + def testJavaTestWithRuntimeRunsRemotely(self): + java_home = os.getenv('JAVA_HOME', 'c:/openjdk') + self.ScratchFile('WORKSPACE') + self.ScratchFile('foo/BUILD', [ + 'package(default_visibility = ["//visibility:public"])', + 'java_test(', + ' name = "foo_test",', + ' srcs = ["TestFoo.java"],', + ' main_class = "TestFoo",', + ' use_testrunner = 0,', + ' data = ["//bar:bar.txt"],', + ')', + 'java_runtime_suite(', + ' name = "jdk8",', + ' default = ":jdk8-default",', + ')', + 'java_runtime(', + ' name = "jdk8-default",', + ' srcs = [],', + ' java_home = "' + java_home + '",', + ')', + ]) + self.ScratchFile( + 'foo/TestFoo.java', [ + 'public class TestFoo {', + 'public static void main(String[] args) {', + 'System.out.println("hello java test");', + '}', + '}', + ], + executable=True) + self.ScratchFile('bar/BUILD', ['exports_files(["bar.txt"])']) + self.ScratchFile('bar/bar.txt', ['hello']) + + # Test. + exit_code, stdout, stderr = self._RunRemoteBazel([ + 'test', '--test_output=all', '--host_javabase=//foo:jdk8', + '--javabase=//foo:jdk8', '//foo:foo_test' + ]) + self.AssertExitCode(exit_code, 0, stderr, stdout) + # Genrules are notably different than tests because RUNFILES_DIR is not set # for genrule tool launchers, so the runfiles directory is discovered based on # the executable path. |