rules_scala icon indicating copy to clipboard operation
rules_scala copied to clipboard

Implicit *_deploy.jar differs when running coverage

Open gergelyfabian opened this issue 3 years ago • 2 comments

It seems that if I have a library target, the library_deploy.jar target will differ if I'm currently running tests with bazel test ... vs. bazel coverage ....

Looking at the execution log I tracked this down to library_java.jar differing.

That target has differences in its inputs:

For coverage:

inputs {
  path: "bazel-out/k8-fastbuild/bin/mylib/library_java-paths-for-coverage.txt"
  digest {
    hash: "43e0f30dd4605f96491357a63ba0a3c02121b9b1b1c40265349e5b351f0643af"
    size_bytes: 213
    hash_function_name: "SHA-256"
  }
}
inputs {
  path: "bazel-out/k8-fastbuild/bin/mylib/library_java.jar-0.params"
  digest {
    hash: "be798145d3ca693ce359bd6a3e5ef4dbeafc6b0b1449af38847e862af2d9df22"
    size_bytes: 13876
    hash_function_name: "SHA-256"
  }
}

Without coverage:

inputs {
  path: "bazel-out/k8-fastbuild/bin/mylib/library_java.jar-0.params"
  digest {
    hash: "bbe9e0d50d0f48880f82b1c1dfd76b4f09314ddd6c3bf6f2bb5ddd5c9d799fde"
    size_bytes: 13717
    hash_function_name: "SHA-256"
  }
}

This is the action's commands, this is:

command_args: "external/jdk8_linux/bin/java"
command_args: "-Xbootclasspath/p:external/remote_java_tools_linux/java_tools/javac-9+181-r4173-1.jar"
command_args: "-jar"
command_args: "external/remote_java_tools_linux/java_tools/JavaBuilder_deploy.jar"
command_args: "@bazel-out/k8-fastbuild/bin/igeolise-lib/library_java.jar-0.params"
command_args: "@bazel-out/k8-fastbuild/bin/igeolise-lib/library_java.jar-1.params"

Is there any valid reason why a *_deploy.jar should be differing when tests are executed with coverage vs. without coverage?

gergelyfabian avatar Jan 14 '22 08:01 gergelyfabian

A workaround may be to set in .bazelrc the following flag:

coverage --build_tests_only

In that case bazel coverage //... won't build (incorrectly) targets that I do not need there.

https://docs.bazel.build/versions/4.2.1/command-line-reference.html#flag--build_tests_only

gergelyfabian avatar Jan 14 '22 08:01 gergelyfabian

It would be good to check if we can build deploy jar out of non-instrumented jars

liucijus avatar Jan 14 '22 09:01 liucijus