aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/java_tools/junitrunner/java/com/google/testing
diff options
context:
space:
mode:
authorGravatar Lukacs Berki <lberki@google.com>2017-01-18 12:18:05 +0000
committerGravatar Vladimir Moskva <vladmos@google.com>2017-01-18 16:01:57 +0000
commit63c9af49bbf3ca7f0d8619a9636bce2b8b70b5c6 (patch)
treeb6081bc1c499ee51a910d96fc92e21ced953a516 /src/java_tools/junitrunner/java/com/google/testing
parentdc61484cb2a090c39b4a2f3768fcad1fef7a7265 (diff)
Jarjar the third-party dependencies of the Jacoco test runner, except on Windows. This way, we don't need a new release to make coverage collection happen.
This is the fifth try on commit 823091f7516abf7d854021edc765daf1467f1647 . This time, it's disabled on Windows because two bugs (#2306 and #2342) collude to make it impossible to run Java binaries during the build on Windows and jarjar is a Java binary. Tested by building //src:bazel on a Windows machine with --output_base=<something with a $ sign in it>. I also verified that the genrule gets run by adding an "exit 1" at its beginning. Fifth time is the charm! Hopefully we don't get to seven. -- PiperOrigin-RevId: 144818587 MOS_MIGRATED_REVID=144818587
Diffstat (limited to 'src/java_tools/junitrunner/java/com/google/testing')
-rw-r--r--src/java_tools/junitrunner/java/com/google/testing/coverage/BUILD33
-rw-r--r--src/java_tools/junitrunner/java/com/google/testing/coverage/JacocoCoverage.jarjar2
2 files changed, 34 insertions, 1 deletions
diff --git a/src/java_tools/junitrunner/java/com/google/testing/coverage/BUILD b/src/java_tools/junitrunner/java/com/google/testing/coverage/BUILD
index 319f13b6d2..3a57a5b4f7 100644
--- a/src/java_tools/junitrunner/java/com/google/testing/coverage/BUILD
+++ b/src/java_tools/junitrunner/java/com/google/testing/coverage/BUILD
@@ -22,7 +22,7 @@ filegroup(
filegroup(
name = "embedded_tools",
srcs = [
- "JacocoCoverage_deploy.jar",
+ "JacocoCoverage_jarjar_deploy.jar",
],
)
@@ -68,3 +68,34 @@ java_library(
"//third_party:apache_commons_lang",
],
)
+
+genrule(
+ name = "Jacoco_jarjar",
+ srcs = [
+ ":JacocoCoverage_deploy.jar",
+ ":JacocoCoverage.jarjar",
+ ],
+ outs = ["JacocoCoverage_jarjar_deploy.jar"],
+ cmd = "\n".join([
+ # Bazel 0.4.3 contains two bugs: a quoting bug in the Java cmd.exe
+ # wrapper script that makes it unable to handle $ signs in paths (#2306)
+ # and one that makes it occasionally put $ signs in the output base
+ # (#2342).
+ #
+ # These two collude to make it impossible to run built Java binaries on
+ # Windows if the output base happens to contain a $ sign.
+ #
+ # Thus, don't call jarjar when on Windows. This makes Java coverage not
+ # work if the code under test uses libraries the test runner also does
+ # (e.g. ASM).
+ #
+ # TODO(lberki): Remove this once a Bazel version with a fix to either of
+ # these bugs is out.
+ "if [[ $$(uname -a) =~ MSYS ]]; then",
+ " cp \"$(location :JacocoCoverage_deploy.jar)\" \"$@\";",
+ "else",
+ " \"$(location //third_party/java/jarjar:jarjar_bin)\" process \"$(location :JacocoCoverage.jarjar)\" \"$(location :JacocoCoverage_deploy.jar)\" \"$@\"",
+ "fi",
+ ]),
+ tools = ["//third_party/java/jarjar:jarjar_bin"],
+)
diff --git a/src/java_tools/junitrunner/java/com/google/testing/coverage/JacocoCoverage.jarjar b/src/java_tools/junitrunner/java/com/google/testing/coverage/JacocoCoverage.jarjar
new file mode 100644
index 0000000000..56190d874c
--- /dev/null
+++ b/src/java_tools/junitrunner/java/com/google/testing/coverage/JacocoCoverage.jarjar
@@ -0,0 +1,2 @@
+rule org.apache.commons.** com.google.testing.coverage.jarjar.@0
+rule org.objectweb.asm.** com.google.testing.coverage.jarjar.@0