Skip to content

Commit 05cd92a

Browse files
committed
Add a bazel xml test formatter
1 parent e077a21 commit 05cd92a

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-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",

test_run.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@ bazel build test/... \
66
&& bazel run test:ScalaBinary \
77
&& bazel run test:ScalaLibBinary \
88
&& bazel run test:JavaBinary \
9-
&& bazel test test/...
9+
&& bazel test test/... \
10+
&& (find -L ./bazel-testlogs -iname "*.scala" | xargs -n1 xmllint > /dev/null) \
11+
&& echo "all good"

0 commit comments

Comments
 (0)