Skip to content

Exception running bazel coverage on java tests #4398

@robfig

Description

@robfig

Description of the problem / feature request:

"bazel coverage" produces an exception internal to bazel

$ bazel clean --expunge
INFO: Starting clean (this may take a while). Consider using --async if the clean takes more than several minutes.

$ bazel coverage --instrumentation_filter=//src/com/corp/profiles //test/com/corp/profiles:unit
...........
INFO: Analysed target //test/com/corp/profiles:unit (171 packages loaded).
INFO: Found 1 test target...
ERROR: /Users/robfig/alpha/src/com/corp/profileservice/validation2/error/BUILD:3:1: Building src/com/corp/profileservice/validation2/error/liberror.jar (3 source files) failed (Exit 1): java failed: error executing command
  (cd /private/var/tmp/_bazel_robfig/1db08896ecff7e5e96a745981c3b77e6/execroot/__main__ && \
  exec env - \
    LC_CTYPE=en_US.UTF-8 \
  external/local_jdk/bin/java -XX:+TieredCompilation '-XX:TieredStopAtLevel=1' -Xbootclasspath/p:external/bazel_tools/third_party/java/jdk/langtools/javac-9-dev-r4023-3.jar -jar external/bazel_tools/tools/jdk/JavaBuilder_deploy.jar @bazel-out/darwin-fastbuild/bin/src/com/corp/profileservice/validation2/error/liberror.jar-2.params)
java.nio.file.DirectoryNotEmptyException: bazel-out/darwin-fastbuild/coverage-metadata/com/corp/profileservice/completion
	at sun.nio.fs.UnixFileSystemProvider.implDelete(UnixFileSystemProvider.java:242)
	at sun.nio.fs.AbstractFileSystemProvider.delete(AbstractFileSystemProvider.java:103)
	at java.nio.file.Files.delete(Files.java:1126)
	at com.google.devtools.build.buildjar.instrumentation.JacocoInstrumentationProcessor$2.postVisitDirectory(JacocoInstrumentationProcessor.java:153)
	at com.google.devtools.build.buildjar.instrumentation.JacocoInstrumentationProcessor$2.postVisitDirectory(JacocoInstrumentationProcessor.java:143)
	at java.nio.file.Files.walkFileTree(Files.java:2688)
	at java.nio.file.Files.walkFileTree(Files.java:2742)
	at com.google.devtools.build.buildjar.instrumentation.JacocoInstrumentationProcessor.recursiveRemove(JacocoInstrumentationProcessor.java:141)
	at com.google.devtools.build.buildjar.instrumentation.JacocoInstrumentationProcessor.processRequest(JacocoInstrumentationProcessor.java:79)
	at com.google.devtools.build.buildjar.SimpleJavaLibraryBuilder.buildJar(SimpleJavaLibraryBuilder.java:140)
	at com.google.devtools.build.buildjar.SimpleJavaLibraryBuilder.run(SimpleJavaLibraryBuilder.java:118)
	at com.google.devtools.build.buildjar.BazelJavaBuilder.processRequest(BazelJavaBuilder.java:105)
	at com.google.devtools.build.buildjar.BazelJavaBuilder.runPersistentWorker(BazelJavaBuilder.java:67)
	at com.google.devtools.build.buildjar.BazelJavaBuilder.main(BazelJavaBuilder.java:45)
Target //test/com/corp/profiles:unit failed to build
INFO: Elapsed time: 111.911s, Critical Path: 39.00s
FAILED: Build did NOT complete successfully

Executed 0 out of 1 test: 1 fails to build.

$ bazel test //test/com/corp/profiles:unit
INFO: Analysed target //test/com/corp/profiles:unit (0 packages loaded).
INFO: Found 1 test target...
Target //test/com/corp/profiles:unit up-to-date:
  bazel-bin/test/com/corp/profiles/unit.jar
  bazel-bin/test/com/corp/profiles/unit
INFO: Elapsed time: 26.749s, Critical Path: 22.90s
INFO: Build completed successfully, 139 total actions
//test/com/corp/profiles:unit                                            PASSED in 5.5s

Executed 1 out of 1 test: 1 test passes.

The directory being complained about does not exist under output_path

$ bazel info
output_path: /private/var/tmp/_bazel_robfig/1db08896ecff7e5e96a745981c3b77e6/execroot/__main__/bazel-out

$ ls /private/var/tmp/_bazel_robfig/1db08896ecff7e5e96a745981c3b77e6/execroot/__main__/bazel-out/darwin-fastbuild/coverage-metadata/com/corp/profileservice/completion
ls: /private/var/tmp/_bazel_robfig/1db08896ecff7e5e96a745981c3b77e6/execroot/__main__/bazel-out/darwin-fastbuild/coverage-metadata/com/corp/profileservice/completion: No such file or directory

Feature requests: what underlying problem are you trying to solve with this feature?

Run java tests with coverage enabled

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

I don't have an open source reproducer. I was hoping the stack trace would be enough

What operating system are you running Bazel on?

Mac OS High Sierra

What's the output of bazel info release?

release 0.9.0

Have you found anything relevant by searching the web?

This appears to be the main discussion about coverage, but it seems to indicate that java coverage is expected to be in working order
#1118

Metadata

Metadata

Assignees

Labels

P1I'll work on this now. (Assignee required)coveragetype: bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions