Skip to content

Commit 470910a

Browse files
committed
Merge pull request #24 from bazelbuild/oscar/fix-xml-reporting
Add a bazel xml test formatter
2 parents e077a21 + 908f9a7 commit 470910a

File tree

5 files changed

+540
-4
lines changed

5 files changed

+540
-4
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ addons:
55
packages:
66
- gcc-4.8
77
- g++-4.8
8+
- libxml2-utils
89
- wget
910
# Package list from http://bazel.io/docs/install.html
1011
- pkg-config

scala/scala.bzl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,7 @@ def _write_test_launcher(ctx, jars):
151151
print("suites attribute is deprecated. All scalatest test suites are run")
152152

153153
content = """#!/bin/bash
154-
cd $0.runfiles
155-
{java} -cp {cp} {name} {args} "$@"
154+
{java} -cp {cp} {name} {args} -C io.bazel.rules.scala.JUnitXmlReporter "$@"
156155
"""
157156
content = content.format(
158157
java=ctx.file._java.path,
@@ -243,7 +242,9 @@ def _scala_binary_impl(ctx):
243242
return _scala_binary_common(ctx, cjars, rjars)
244243

245244
def _scala_test_impl(ctx):
246-
jars = _collect_jars(ctx.attr.deps)
245+
deps = ctx.attr.deps
246+
deps += [ctx.attr._scalatest_reporter]
247+
jars = _collect_jars(deps)
247248
(cjars, rjars) = (jars.compiletime, jars.runtime)
248249
cjars += [ctx.file._scalareflect, ctx.file._scalatest, ctx.file._scalaxml]
249250
rjars += [ctx.outputs.jar, ctx.file._scalalib, ctx.file._scalareflect, ctx.file._scalatest, ctx.file._scalaxml]
@@ -318,6 +319,7 @@ scala_test = rule(
318319
"main_class": attr.string(default="org.scalatest.tools.Runner"),
319320
"suites": attr.string_list(),
320321
"_scalatest": attr.label(executable=True, default=Label("@scalatest//file"), single_file=True, allow_files=True),
322+
"_scalatest_reporter": attr.label(default=Label("//scala/support:test_reporter")),
321323
} + _implicit_deps + _common_attrs,
322324
outputs={
323325
"jar": "%{name}_deploy.jar",

scala/support/BUILD

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
load("//scala:scala.bzl", "scala_library")
2+
3+
scala_library(name = "test_reporter",
4+
srcs = ["JUnitXmlReporter.scala"],
5+
deps = ["@scalatest//file"],
6+
visibility = ["//visibility:public"],
7+
)

0 commit comments

Comments
 (0)