Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coverage with custom jacocorunner jar file - what am I doing wrong? #1453

Open
pcj opened this issue Nov 29, 2022 · 16 comments
Open

Coverage with custom jacocorunner jar file - what am I doing wrong? #1453

pcj opened this issue Nov 29, 2022 · 16 comments

Comments

@pcj
Copy link
Member

pcj commented Nov 29, 2022

Trying to get coverage working for a repository after upgrading rules_scala to a40063ef97688f056824b22b9e49fae6efd1df0f and bazel 5.1.1.

@pcj
Copy link
Member Author

pcj commented Nov 29, 2022

Checked out rules_scala at 73f5d1a7da081c9f5160b9ed7ac745388af28e23 and built the custom deploy jar as follows:

I then edited the test.sh file to use the bazel 5 version:

 build_local_jacocorunner() {
-    $root_dir/scripts/build_jacocorunner/build_jacocorunner.sh
+    $root_dir/scripts/build_jacocorunner/build_jacocorunner_bazel_5.0+.sh
     cp /tmp/bazel_jacocorunner_build/JacocoCoverage_jarjar_deploy.jar $root_dir/manual_test/coverage_local_jacocorunner
 }
$ cd manual_test/coverage_local_jacocorunner
$ ./test.sh

With the custom jar built (all mvn tests passed), packed it into a zip file:

$ jar -cfM jacoco-coverage-73f5d1.zip ./JacocoCoverage_jarjar_deploy.jar

And uploaded that zip file here:

jacoco-coverage-73f5d1.zip

@pcj
Copy link
Member Author

pcj commented Nov 29, 2022

The zip file can be consumed as an http_archive as follows:

    http_archive(
        name = "rules_scala_jacocorunner",
        sha256 = "1e21d640ac5e39bff30c6255b2de389b0a53adf2338aeeeb5a656b13de11ba2b",
        urls = ["https://github.com/bazelbuild/rules_scala/files/10109719/jacoco-coverage-73f5d1.zip"],
        build_file_content = """
filegroup(
    name = "jar",
    srcs = ["JacocoCoverage_jarjar_deploy.jar"],
    visibility = ["//visibility:public"],
)
        """,
    )

@pcj
Copy link
Member Author

pcj commented Nov 29, 2022

A custom scala_toolchain was setup:

load("@io_bazel_rules_scala//scala:scala_toolchain.bzl", "scala_toolchain")

scala_toolchain(
    name = "jacocorunner_toolchain_impl",
    jacocorunner = "@rules_scala_jacocorunner//:jar",
    unused_dependency_checker_mode = "error",
    visibility = ["//visibility:public"],
)

toolchain(
    name = "jacocorunner_scala_toolchain",
    toolchain = "jacocorunner_toolchain_impl",
    toolchain_type = "@io_bazel_rules_scala//scala:toolchain_type",
    visibility = ["//visibility:public"],
)

@pcj
Copy link
Member Author

pcj commented Nov 29, 2022

The toolchain was registered in the WORKSPACE:

register_toolchains(
    "//bazel_tools/scala:jacocorunner_scala_toolchain",
)

@pcj
Copy link
Member Author

pcj commented Nov 29, 2022

Salient .bazelrc flags:

build --java_language_version=17
build --tool_java_language_version=17
build --java_runtime_version=remotejdk_17
build --tool_java_runtime_version=remotejdk_17
coverage --combined_report=lcov
coverage --coverage_report_generator="@bazel_tools//tools/test/CoverageOutputGenerator/java/com/google/devtools/coverageoutputgenerator:Main"

@pcj
Copy link
Member Author

pcj commented Nov 29, 2022

Despite all this, coverage.dat files are always empty:

bazel coverage //common/auth:tests
INFO: Invocation ID: 9a653f7d-2864-4208-80cd-aa4bdb558f10
INFO: Using default value for --instrumentation_filter: "^//common/auth[/:]".
INFO: Override the above default with --instrumentation_filter
INFO: Analyzed target //common/auth:tests (0 packages loaded, 0 targets configured).
INFO: Found 1 test target...
INFO: LCOV coverage report is located at /private/var/tmp/_bazel_i868039/f9bbdd40f3eca77219d10972abb94836/execroot/foo/bazel-out/_coverage/_coverage_report.dat
 and execpath is bazel-out/_coverage/_coverage_report.dat
INFO: From Coverage report generation:
Nov 28, 2022 8:58:32 PM com.google.devtools.coverageoutputgenerator.Main getTracefiles
INFO: Found 1 tracefiles.
Nov 28, 2022 8:58:32 PM com.google.devtools.coverageoutputgenerator.Main parseFilesSequentially
INFO: Parsing file bazel-out/darwin-fastbuild/testlogs/common/auth/tests/coverage.dat
Nov 28, 2022 8:58:32 PM com.google.devtools.coverageoutputgenerator.Main getGcovInfoFiles
INFO: No gcov info file found.
Nov 28, 2022 8:58:32 PM com.google.devtools.coverageoutputgenerator.Main getGcovJsonInfoFiles
INFO: No gcov json file found.
Nov 28, 2022 8:58:32 PM com.google.devtools.coverageoutputgenerator.Main getProfdataFileOrNull
INFO: No .profdata file found.
Nov 28, 2022 8:58:32 PM com.google.devtools.coverageoutputgenerator.Main runWithArgs
WARNING: There was no coverage found.
Target //common/auth:tests up-to-date:
  bazel-bin/common/auth/tests.jar
  bazel-bin/common/auth/tests.sh
INFO: Elapsed time: 0.528s, Critical Path: 0.14s
INFO: 2 processes: 1 disk cache hit, 1 internal.
INFO: Build completed successfully, 2 total actions

Executed 0 out of 1 test: 1 test passes.
INFO: Build completed successfully, 2 total actions
$ du -sh /private/var/tmp/_bazel_i868039/f9bbdd40f3eca77219d10972abb94836/execroot/foo/bazel-out/_coverage/_coverage_report.dat
0	/private/var/tmp/_bazel_i868039/f9bbdd40f3eca77219d10972abb94836/execroot/foo/bazel-out/_coverage/_coverage_report.dat

NOTE: the flag --instrument_test_targets=true seems to make no difference

@pcj
Copy link
Member Author

pcj commented Nov 29, 2022

bazel version
Build label: 5.1.1- (@non-git)
Build target: bazel-out/darwin-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Sat May 21 09:38:24 2022 (1653125904)
Build timestamp: 1653125904
Build timestamp as int: 1653125904

@pcj pcj changed the title Custom jacocorunner jar file coverage with custom jacocorunner jar file - what am I doing wrong? Nov 29, 2022
@pcj pcj changed the title coverage with custom jacocorunner jar file - what am I doing wrong? Coverage with custom jacocorunner jar file - what am I doing wrong? Nov 29, 2022
@pcj
Copy link
Member Author

pcj commented Nov 29, 2022

cc @gergelyfabian any suggestions here?

@gergelyfabian
Copy link
Contributor

Did you try playing with the --instrumentation_filter parameter?

@gergelyfabian
Copy link
Contributor

gergelyfabian commented Nov 29, 2022

Please check https://github.com/gergelyfabian/bazel-scala-example. I've updated it to use Bazel 5.3.2 and Java 17.
On branch https://github.com/gergelyfabian/bazel-scala-example/tree/jacoco_coverage_fix_new I'm using a custom jacocorunner jar. Please try it by placing the custom built jar to tools/JacocoCoverage_jarjar_deploy.jar while using this repo and branch.

Tried with:

bazel coverage //...
lcov --list bazel-out/_coverage/_coverage_report.dat

@gergelyfabian
Copy link
Contributor

rules_scala is on version 73f5d1a7da081c9f5160b9ed7ac745388af28e23 in my example.

@pcj
Copy link
Member Author

pcj commented Nov 30, 2022

Indeed things are working in that example, with the custom JacocoCoverage_jarjar_deploy.jar uploaded to this issue.

shasum -a256 tools/JacocoCoverage_jarjar_deploy.jar 
66a0a251086895241063adf23f2773bd7ebe1ba0762612871a0d50d8c81a58fd  tools/JacocoCoverage_jarjar_deploy.jar
bazel-scala-example % git status
On branch jacoco_coverage_fix_new
Your branch is up to date with 'origin/jacoco_coverage_fix_new'.

Untracked files:
  (use "git add <file>..." to include in what will be committed)
	tools/JacocoCoverage_jarjar_deploy.jar
lcov --list bazel-out/_coverage/_coverage_report.dat
Reading tracefile bazel-out/_coverage/_coverage_report.dat
                                   |Lines       |Functions  |Branches    
Filename                           |Rate     Num|Rate    Num|Rate     Num
=========================================================================
[example-lib/src/main/]
java/mypackage/Greeter.java        | 0.0%     19| 0.0%     6|    -      0
scala/mypackage/Foo.scala          | 100%     20|52.6%    38|    -      0

[example-maven/src/main/scala/mypackage/]
Maven.scala                        | 100%      2|66.7%     3|    -      0
=========================================================================
                             Total:|53.7%     41|46.8%    47|    -      0

Clearly something different about the repository I'm using it within (not sure yet what it is) but at least this is a good sanity check so thank you @gergelyfabian for setting up this example.

@pcj
Copy link
Member Author

pcj commented Dec 17, 2022

Just leaving a trail here for my future self, or someone else... Seeing an exception from the jacocorunner, not sure what it means yet.

In the repo I'm working with, copying the example-lib/ into it and running coverage works for those simple targets. But running it for "real" targets always yields empty coverage.dat files.

Here's what I see with --test_env=VERBOSE_COVERAGE=1 flag:

bazel coverage \
  //common/utils/caseclass/... \
  --experimental_fetch_all_coverage_outputs \
  --instrumentation_filter=//common/utils/caseclass \
  --test_output=all \
  --experimental_split_coverage_postprocessing \
  --test_env=VERBOSE_COVERAGE=1 
  --spawn_strategy=standalone
INFO: Invocation ID: 612902eb-19b6-48b3-99c8-541a00a179dd
Loading: 
Loading: 0 packages loaded
Analyzing: 2 targets (0 packages loaded, 0 targets configured)
DEBUG: /private/var/tmp/_bazel_pcj/d7e82b68b84ece06dc82c3639a1eabcf/external/io_bazel_rules_scala/scala/private/phases/phase_coverage.bzl:57:14: running jacoco instrumenter! //trumid/common/utils/caseclass:scala
DEBUG: /private/var/tmp/_bazel_pcj/d7e82b68b84ece06dc82c3639a1eabcf/external/io_bazel_rules_scala/scala/private/phases/phase_coverage_runfiles.bzl:27:18: coverage runfile: tools/JacocoCoverage_jarjar_deploy.jar
DEBUG: /private/var/tmp/_bazel_pcj/d7e82b68b84ece06dc82c3639a1eabcf/external/io_bazel_rules_scala/scala/private/phases/phase_coverage_runfiles.bzl:27:18: coverage runfile: ../remote_coverage_tools/Main.jar
DEBUG: /private/var/tmp/_bazel_pcj/d7e82b68b84ece06dc82c3639a1eabcf/external/io_bazel_rules_scala/scala/private/phases/phase_coverage_runfiles.bzl:27:18: coverage runfile: ../remote_coverage_tools/Main
DEBUG: /private/var/tmp/_bazel_pcj/d7e82b68b84ece06dc82c3639a1eabcf/external/io_bazel_rules_scala/scala/private/phases/phase_coverage_runfiles.bzl:27:18: coverage runfile: trumid/common/utils/caseclass/scala-offline.jar
INFO: Analyzed 2 targets (0 packages loaded, 0 targets configured).
INFO: Found 1 target and 1 test target...
[3 / 6] [Prepa] BazelWorkspaceStatusAction stable-status.txt ... (2 actions, 0 running)
FAIL: //trumid/common/utils/caseclass:tests (see /private/var/tmp/_bazel_pcj/d7e82b68b84ece06dc82c3639a1eabcf/execroot/unity/bazel-out/darwin_arm64-fastbuild/testlogs/trumid/common/utils/caseclass/tests/test.log)
INFO: From Testing //trumid/common/utils/caseclass:tests:
==================== Test output for //trumid/common/utils/caseclass:tests:
+ [[ -z bazel-out/darwin_arm64-fastbuild/bin/trumid/common/utils/caseclass/tests.instrumented_files ]]
+ export ROOT=/private/var/tmp/_bazel_pcj/d7e82b68b84ece06dc82c3639a1eabcf/execroot/unity
+ ROOT=/private/var/tmp/_bazel_pcj/d7e82b68b84ece06dc82c3639a1eabcf/execroot/unity
+ [[ bazel-out/darwin_arm64-fastbuild/bin/trumid/common/utils/caseclass/tests.instrumented_files != /* ]]
+ export COVERAGE_MANIFEST=/private/var/tmp/_bazel_pcj/d7e82b68b84ece06dc82c3639a1eabcf/execroot/unity/bazel-out/darwin_arm64-fastbuild/bin/trumid/common/utils/caseclass/tests.instrumented_files
+ COVERAGE_MANIFEST=/private/var/tmp/_bazel_pcj/d7e82b68b84ece06dc82c3639a1eabcf/execroot/unity/bazel-out/darwin_arm64-fastbuild/bin/trumid/common/utils/caseclass/tests.instrumented_files
+ export COVERAGE_DIR=bazel-out/darwin_arm64-fastbuild/testlogs/trumid/common/utils/caseclass/tests/_coverage
+ COVERAGE_DIR=bazel-out/darwin_arm64-fastbuild/testlogs/trumid/common/utils/caseclass/tests/_coverage
+ [[ bazel-out/darwin_arm64-fastbuild/testlogs/trumid/common/utils/caseclass/tests/_coverage == /private/var/tmp/_bazel_pcj/d7e82b68b84ece06dc82c3639a1eabcf/execroot/unity* ]]
+ COVERAGE_DIR=/private/var/tmp/_bazel_pcj/d7e82b68b84ece06dc82c3639a1eabcf/execroot/unity/bazel-out/darwin_arm64-fastbuild/testlogs/trumid/common/utils/caseclass/tests/_coverage
+ mkdir -p /private/var/tmp/_bazel_pcj/d7e82b68b84ece06dc82c3639a1eabcf/execroot/unity/bazel-out/darwin_arm64-fastbuild/testlogs/trumid/common/utils/caseclass/tests/_coverage
+ COVERAGE_OUTPUT_FILE=bazel-out/darwin_arm64-fastbuild/testlogs/trumid/common/utils/caseclass/tests/coverage.dat
+ [[ bazel-out/darwin_arm64-fastbuild/testlogs/trumid/common/utils/caseclass/tests/coverage.dat == /private/var/tmp/_bazel_pcj/d7e82b68b84ece06dc82c3639a1eabcf/execroot/unity* ]]
+ COVERAGE_OUTPUT_FILE=/private/var/tmp/_bazel_pcj/d7e82b68b84ece06dc82c3639a1eabcf/execroot/unity/bazel-out/darwin_arm64-fastbuild/testlogs/trumid/common/utils/caseclass/tests/coverage.dat
+ export JAVA_COVERAGE_FILE=/private/var/tmp/_bazel_pcj/d7e82b68b84ece06dc82c3639a1eabcf/execroot/unity/bazel-out/darwin_arm64-fastbuild/testlogs/trumid/common/utils/caseclass/tests/_coverage/jvcov.dat
+ JAVA_COVERAGE_FILE=/private/var/tmp/_bazel_pcj/d7e82b68b84ece06dc82c3639a1eabcf/execroot/unity/bazel-out/darwin_arm64-fastbuild/testlogs/trumid/common/utils/caseclass/tests/_coverage/jvcov.dat
+ export COVERAGE=1
+ COVERAGE=1
+ export BULK_COVERAGE_RUN=1
+ BULK_COVERAGE_RUN=1
+ [[ -z '' ]]
+ export GCOV_PREFIX_STRIP=3
+ GCOV_PREFIX_STRIP=3
+ export GCOV_PREFIX=/private/var/tmp/_bazel_pcj/d7e82b68b84ece06dc82c3639a1eabcf/execroot/unity/bazel-out/darwin_arm64-fastbuild/testlogs/trumid/common/utils/caseclass/tests/_coverage
+ GCOV_PREFIX=/private/var/tmp/_bazel_pcj/d7e82b68b84ece06dc82c3639a1eabcf/execroot/unity/bazel-out/darwin_arm64-fastbuild/testlogs/trumid/common/utils/caseclass/tests/_coverage
+ export LLVM_PROFILE_FILE=/private/var/tmp/_bazel_pcj/d7e82b68b84ece06dc82c3639a1eabcf/execroot/unity/bazel-out/darwin_arm64-fastbuild/testlogs/trumid/common/utils/caseclass/tests/_coverage/%h-%p-%m.profraw
+ LLVM_PROFILE_FILE=/private/var/tmp/_bazel_pcj/d7e82b68b84ece06dc82c3639a1eabcf/execroot/unity/bazel-out/darwin_arm64-fastbuild/testlogs/trumid/common/utils/caseclass/tests/_coverage/%h-%p-%m.profraw
+ [[ ! -z '' ]]
+ [[ 0 == \0 ]]
+ cd /private/var/tmp/_bazel_pcj/d7e82b68b84ece06dc82c3639a1eabcf/execroot/unity/bazel-out/darwin_arm64-fastbuild/bin/trumid/common/utils/caseclass/tests.sh.runfiles/unity
+ [[ 1 == \0 ]]
+ /private/var/tmp/_bazel_pcj/d7e82b68b84ece06dc82c3639a1eabcf/execroot/unity/bazel-out/darwin_arm64-fastbuild/bin/trumid/common/utils/caseclass/tests.sh.runfiles/unity/trumid/common/utils/caseclass/tests.sh
Discovery starting.
Discovery completed in 58 milliseconds.
Run starting. Expected test count is: 1
CaseClassFactoryTest:
- should instantiate a case class from it's corresponding tuple (7 milliseconds)
Run completed in 100 milliseconds.
Total number of tests run: 1
Suites: completed 2, aborted 0
Tests: succeeded 1, failed 0, canceled 0, ignored 0, pending 0
All tests passed.
+ TEST_STATUS=0
+ [[ 0 -ne 0 ]]
+ [[ 1 == \1 ]]
+ [[ 0 == \0 ]]
+ exit 0
+ [[ -z bazel-out/darwin_arm64-fastbuild/bin/trumid/common/utils/caseclass/tests.instrumented_files ]]
+ export ROOT=/private/var/tmp/_bazel_pcj/d7e82b68b84ece06dc82c3639a1eabcf/execroot/unity
+ ROOT=/private/var/tmp/_bazel_pcj/d7e82b68b84ece06dc82c3639a1eabcf/execroot/unity
+ [[ bazel-out/darwin_arm64-fastbuild/bin/trumid/common/utils/caseclass/tests.instrumented_files != /* ]]
+ export COVERAGE_MANIFEST=/private/var/tmp/_bazel_pcj/d7e82b68b84ece06dc82c3639a1eabcf/execroot/unity/bazel-out/darwin_arm64-fastbuild/bin/trumid/common/utils/caseclass/tests.instrumented_files
+ COVERAGE_MANIFEST=/private/var/tmp/_bazel_pcj/d7e82b68b84ece06dc82c3639a1eabcf/execroot/unity/bazel-out/darwin_arm64-fastbuild/bin/trumid/common/utils/caseclass/tests.instrumented_files
+ export COVERAGE_DIR=bazel-out/darwin_arm64-fastbuild/testlogs/trumid/common/utils/caseclass/tests/_coverage
+ COVERAGE_DIR=bazel-out/darwin_arm64-fastbuild/testlogs/trumid/common/utils/caseclass/tests/_coverage
+ [[ bazel-out/darwin_arm64-fastbuild/testlogs/trumid/common/utils/caseclass/tests/_coverage == /private/var/tmp/_bazel_pcj/d7e82b68b84ece06dc82c3639a1eabcf/execroot/unity* ]]
+ COVERAGE_DIR=/private/var/tmp/_bazel_pcj/d7e82b68b84ece06dc82c3639a1eabcf/execroot/unity/bazel-out/darwin_arm64-fastbuild/testlogs/trumid/common/utils/caseclass/tests/_coverage
+ mkdir -p /private/var/tmp/_bazel_pcj/d7e82b68b84ece06dc82c3639a1eabcf/execroot/unity/bazel-out/darwin_arm64-fastbuild/testlogs/trumid/common/utils/caseclass/tests/_coverage
+ COVERAGE_OUTPUT_FILE=bazel-out/darwin_arm64-fastbuild/testlogs/trumid/common/utils/caseclass/tests/coverage.dat
+ [[ bazel-out/darwin_arm64-fastbuild/testlogs/trumid/common/utils/caseclass/tests/coverage.dat == /private/var/tmp/_bazel_pcj/d7e82b68b84ece06dc82c3639a1eabcf/execroot/unity* ]]
+ COVERAGE_OUTPUT_FILE=/private/var/tmp/_bazel_pcj/d7e82b68b84ece06dc82c3639a1eabcf/execroot/unity/bazel-out/darwin_arm64-fastbuild/testlogs/trumid/common/utils/caseclass/tests/coverage.dat
+ export JAVA_COVERAGE_FILE=/private/var/tmp/_bazel_pcj/d7e82b68b84ece06dc82c3639a1eabcf/execroot/unity/bazel-out/darwin_arm64-fastbuild/testlogs/trumid/common/utils/caseclass/tests/_coverage/jvcov.dat
+ JAVA_COVERAGE_FILE=/private/var/tmp/_bazel_pcj/d7e82b68b84ece06dc82c3639a1eabcf/execroot/unity/bazel-out/darwin_arm64-fastbuild/testlogs/trumid/common/utils/caseclass/tests/_coverage/jvcov.dat
+ export COVERAGE=1
+ COVERAGE=1
+ export BULK_COVERAGE_RUN=1
+ BULK_COVERAGE_RUN=1
+ [[ -z '' ]]
+ export GCOV_PREFIX_STRIP=3
+ GCOV_PREFIX_STRIP=3
+ export GCOV_PREFIX=/private/var/tmp/_bazel_pcj/d7e82b68b84ece06dc82c3639a1eabcf/execroot/unity/bazel-out/darwin_arm64-fastbuild/testlogs/trumid/common/utils/caseclass/tests/_coverage
+ GCOV_PREFIX=/private/var/tmp/_bazel_pcj/d7e82b68b84ece06dc82c3639a1eabcf/execroot/unity/bazel-out/darwin_arm64-fastbuild/testlogs/trumid/common/utils/caseclass/tests/_coverage
+ export LLVM_PROFILE_FILE=/private/var/tmp/_bazel_pcj/d7e82b68b84ece06dc82c3639a1eabcf/execroot/unity/bazel-out/darwin_arm64-fastbuild/testlogs/trumid/common/utils/caseclass/tests/_coverage/%h-%p-%m.profraw
+ LLVM_PROFILE_FILE=/private/var/tmp/_bazel_pcj/d7e82b68b84ece06dc82c3639a1eabcf/execroot/unity/bazel-out/darwin_arm64-fastbuild/testlogs/trumid/common/utils/caseclass/tests/_coverage/%h-%p-%m.profraw
+ [[ ! -z '' ]]
+ [[ 1 == \0 ]]
+ [[ 1 == \1 ]]
+ [[ 1 == \0 ]]
+ [[ 1 == \1 ]]
+ [[ 1 == \1 ]]
+ touch /private/var/tmp/_bazel_pcj/d7e82b68b84ece06dc82c3639a1eabcf/execroot/unity/bazel-out/darwin_arm64-fastbuild/testlogs/trumid/common/utils/caseclass/tests/coverage.dat
+ cd /private/var/tmp/_bazel_pcj/d7e82b68b84ece06dc82c3639a1eabcf/execroot/unity
+ [[ -n '' ]]
+ [[ -z bazel-out/darwin_arm64-fastbuild/bin/external/remote_coverage_tools/Main ]]
+ for name in "$LCOV_MERGER"
+ [[ ! -e bazel-out/darwin_arm64-fastbuild/bin/external/remote_coverage_tools/Main ]]
+ [[ 1 == \1 ]]
++ resolve_links /private/var/tmp/_bazel_pcj/d7e82b68b84ece06dc82c3639a1eabcf/execroot/unity/bazel-out/darwin_arm64-fastbuild/testlogs/trumid/common/utils/caseclass/tests/_coverage
++ local name=/private/var/tmp/_bazel_pcj/d7e82b68b84ece06dc82c3639a1eabcf/execroot/unity/bazel-out/darwin_arm64-fastbuild/testlogs/trumid/common/utils/caseclass/tests/_coverage
++ '[' -e /private/var/tmp/_bazel_pcj/d7e82b68b84ece06dc82c3639a1eabcf/execroot/unity/bazel-out/darwin_arm64-fastbuild/testlogs/trumid/common/utils/caseclass/tests/_coverage ']'
++ '[' -L /private/var/tmp/_bazel_pcj/d7e82b68b84ece06dc82c3639a1eabcf/execroot/unity/bazel-out/darwin_arm64-fastbuild/testlogs/common/utils/caseclass/tests/_coverage ']'
++ echo /private/var/tmp/_bazel_pcj/d7e82b68b84ece06dc82c3639a1eabcf/execroot/unity/bazel-out/darwin_arm64-fastbuild/testlogs/common/utils/caseclass/tests/_coverage
+ COVERAGE_DIR=/private/var/tmp/_bazel_pcj/d7e82b68b84ece06dc82c3639a1eabcf/execroot/unity/bazel-out/darwin_arm64-fastbuild/testlogs/common/utils/caseclass/tests/_coverage
++ resolve_links /private/var/tmp/_bazel_pcj/d7e82b68b84ece06dc82c3639a1eabcf/execroot/unity/bazel-out/darwin_arm64-fastbuild/bin/common/utils/caseclass/tests.instrumented_files
++ local name=/private/var/tmp/_bazel_pcj/d7e82b68b84ece06dc82c3639a1eabcf/execroot/unity/bazel-out/darwin_arm64-fastbuild/bin/common/utils/caseclass/tests.instrumented_files
++ '[' -e /private/var/tmp/_bazel_pcj/d7e82b68b84ece06dc82c3639a1eabcf/execroot/unity/bazel-out/darwin_arm64-fastbuild/bin/common/utils/caseclass/tests.instrumented_files ']'
++ '[' -L /private/var/tmp/_bazel_pcj/d7e82b68b84ece06dc82c3639a1eabcf/execroot/unity/bazel-out/darwin_arm64-fastbuild/bin/common/utils/caseclass/tests.instrumented_files ']'
++ echo /private/var/tmp/_bazel_pcj/d7e82b68b84ece06dc82c3639a1eabcf/execroot/unity/bazel-out/darwin_arm64-fastbuild/bin/common/utils/caseclass/tests.instrumented_files
+ COVERAGE_MANIFEST=/private/var/tmp/_bazel_pcj/d7e82b68b84ece06dc82c3639a1eabcf/execroot/unity/bazel-out/darwin_arm64-fastbuild/bin/common/utils/caseclass/tests.instrumented_files
+ LCOV_MERGER_CMD='bazel-out/darwin_arm64-fastbuild/bin/external/remote_coverage_tools/Main --coverage_dir=/private/var/tmp/_bazel_pcj/d7e82b68b84ece06dc82c3639a1eabcf/execroot/unity/bazel-out/darwin_arm64-fastbuild/testlogs/common/utils/caseclass/tests/_coverage   --output_file=/private/var/tmp/_bazel_pcj/d7e82b68b84ece06dc82c3639a1eabcf/execroot/unity/bazel-out/darwin_arm64-fastbuild/testlogs/common/utils/caseclass/tests/coverage.dat   --filter_sources=/usr/bin/.+   --filter_sources=/usr/lib/.+   --filter_sources=/usr/include.+   --filter_sources=/Applications/.+   --filter_sources=.*external/.+   --source_file_manifest=/private/var/tmp/_bazel_pcj/d7e82b68b84ece06dc82c3639a1eabcf/execroot/unity/bazel-out/darwin_arm64-fastbuild/bin/common/utils/caseclass/tests.instrumented_files'
+ [[ -n '' ]]
+ [[ -n '' ]]
+ JAVA_RUNFILES=
+ exec bazel-out/darwin_arm64-fastbuild/bin/external/remote_coverage_tools/Main --coverage_dir=/private/var/tmp/_bazel_pcj/d7e82b68b84ece06dc82c3639a1eabcf/execroot/unity/bazel-out/darwin_arm64-fastbuild/testlogs/common/utils/caseclass/tests/_coverage --output_file=/private/var/tmp/_bazel_pcj/d7e82b68b84ece06dc82c3639a1eabcf/execroot/unity/bazel-out/darwin_arm64-fastbuild/testlogs/common/utils/caseclass/tests/coverage.dat --filter_sources=/usr/bin/.+ --filter_sources=/usr/lib/.+ --filter_sources=/usr/include.+ --filter_sources=/Applications/.+ '--filter_sources=.*external/.+' --source_file_manifest=/private/var/tmp/_bazel_pcj/d7e82b68b84ece06dc82c3639a1eabcf/execroot/unity/bazel-out/darwin_arm64-fastbuild/bin/common/utils/caseclass/tests.instrumented_files
Dec 17, 2022 6:12:20 PM com.google.devtools.coverageoutputgenerator.Main getTracefiles
INFO: Found 1 tracefiles.
Dec 17, 2022 6:12:20 PM com.google.devtools.coverageoutputgenerator.Main parseFilesSequentially
INFO: Parsing file /private/var/tmp/_bazel_pcj/d7e82b68b84ece06dc82c3639a1eabcf/execroot/unity/bazel-out/darwin_arm64-fastbuild/testlogs/common/utils/caseclass/tests/_coverage/jvcov11223020425242003820.dat
Dec 17, 2022 6:12:20 PM com.google.devtools.coverageoutputgenerator.Main getGcovInfoFiles
INFO: No gcov info file found.
Dec 17, 2022 6:12:20 PM com.google.devtools.coverageoutputgenerator.Main getGcovJsonInfoFiles
INFO: No gcov json file found.
Dec 17, 2022 6:12:20 PM com.google.devtools.coverageoutputgenerator.Main getProfdataFileOrNull
INFO: No .profdata file found.
Dec 17, 2022 6:12:20 PM com.google.devtools.coverageoutputgenerator.Main runWithArgs
WARNING: There was no coverage found.
java.io.IOException: Permission denied
	at java.base/java.io.UnixFileSystem.createFileExclusively(Native Method)
	at java.base/java.io.File.createTempFile(File.java:2170)
	at com.google.testing.coverage.JacocoCoverageRunner.getUniquePath(JacocoCoverageRunner.java:345)
	at com.google.testing.coverage.JacocoCoverageRunner$2.run(JacocoCoverageRunner.java:519)
================================================================================
INFO: LCOV coverage report is located at /private/var/tmp/_bazel_pcj/d7e82b68b84ece06dc82c3639a1eabcf/execroot/unity/bazel-out/_coverage/_coverage_report.dat
 and execpath is bazel-out/_coverage/_coverage_report.dat
INFO: Elapsed time: 0.933s, Critical Path: 0.67s
INFO: 2 processes: 1 internal, 1 local.
INFO: Build completed, 1 test FAILED, 2 total actions
//common/utils/caseclass:tests                                    FAILED in 0.5s
  /private/var/tmp/_bazel_pcj/d7e82b68b84ece06dc82c3639a1eabcf/execroot/unity/bazel-out/darwin_arm64-fastbuild/testlogs/common/utils/caseclass/tests/test.log

Executed 1 out of 1 test: 1 fails locally.
INFO: Build completed, 1 test FAILED, 2 total actions

Particularly the permission denied bit:

java.io.IOException: Permission denied
	at java.base/java.io.UnixFileSystem.createFileExclusively(Native Method)
	at java.base/java.io.File.createTempFile(File.java:2170)
	at com.google.testing.coverage.JacocoCoverageRunner.getUniquePath(JacocoCoverageRunner.java:345)
	at com.google.testing.coverage.JacocoCoverageRunner$2.run(JacocoCoverageRunner.java:519)

@gergelyfabian
Copy link
Contributor

gergelyfabian commented Dec 17, 2022 via email

@gergelyfabian
Copy link
Contributor

gergelyfabian commented Dec 17, 2022 via email

@pcj
Copy link
Member Author

pcj commented Feb 22, 2024

Circling back to this to note that, some time ago, I created https://github.com/stackb/bazel-jacocorunner.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants