Post-process bazel test command generated reports

Viewed 799

I'm using Bazel on my CI server for building and testing my C++ library, but I can't retrieve generated reports/logs files.

I wonder if there is a way to refer to those generated files for a further use inside a genrule which can permit me to post-process files (generate HTML...) ?

bazel execution :

$ bazel test //unit:tests
INFO: Analyzed 2 targets (21 packages loaded, 400 targets configured).
INFO: Found 2 test targets...
INFO: Elapsed time: 29,326s, Critical Path: 6,86s
INFO: 22 processes: 22 darwin-sandbox.
INFO: Build completed successfully, 29 total actions
//unit:tests_a                                                 PASSED in 0.7s
//unit:tests_b                                                 PASSED in 0.7s

Executed 2 out of 2 tests: 2 tests pass.
INFO: Build completed successfully, 29 total actions

generated reports :

$ find bazel-out/ -name '*.xml' -or -name '*.log'
bazel-out//darwin-fastbuild/testlogs/unit/tests_a/test.log
bazel-out//darwin-fastbuild/testlogs/unit/tests_a/test.xml
bazel-out//darwin-fastbuild/testlogs/unit/tests_b/test.log
bazel-out//darwin-fastbuild/testlogs/unit/tests_b/test.xml

WORKSPACE :

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
    name = "gtest",
    url = "https://github.com/google/googletest/archive/release-1.10.0.zip",
    sha256 = "94c634d499558a76fa649edb13721dce6e98fb1e7018dfaeba3cd7a083945e91",
    strip_prefix = "googletest-release-1.10.0",
)

unit/BUILD :

load("@rules_cc//cc:defs.bzl", "cc_test")
test_suite(name = "tests", tests = glob(["tests_*"]))
cc_test(name = "tests_a", srcs = ["ut.cc"], deps = ["@gtest//:gtest_main"])
cc_test(name = "tests_b", srcs = ["ut.cc"], deps = ["@gtest//:gtest_main"])

unit/ut.cc :

#include "gtest/gtest.h"
TEST(HelloTest, GetGreet) {
  EXPECT_EQ(1, 1);
}
1 Answers
Related