Skip to content

Commit

Permalink
Merge pull request #24 from bazelbuild/oscar/fix-xml-reporting
Browse files Browse the repository at this point in the history
Add a bazel xml test formatter
  • Loading branch information
johnynek committed Apr 1, 2016
2 parents e077a21 + 908f9a7 commit 470910a
Show file tree
Hide file tree
Showing 5 changed files with 540 additions and 4 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ addons:
packages:
- gcc-4.8
- g++-4.8
- libxml2-utils
- wget
# Package list from http://bazel.io/docs/install.html
- pkg-config
Expand Down
8 changes: 5 additions & 3 deletions scala/scala.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,7 @@ def _write_test_launcher(ctx, jars):
print("suites attribute is deprecated. All scalatest test suites are run")

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

def _scala_test_impl(ctx):
jars = _collect_jars(ctx.attr.deps)
deps = ctx.attr.deps
deps += [ctx.attr._scalatest_reporter]
jars = _collect_jars(deps)
(cjars, rjars) = (jars.compiletime, jars.runtime)
cjars += [ctx.file._scalareflect, ctx.file._scalatest, ctx.file._scalaxml]
rjars += [ctx.outputs.jar, ctx.file._scalalib, ctx.file._scalareflect, ctx.file._scalatest, ctx.file._scalaxml]
Expand Down Expand Up @@ -318,6 +319,7 @@ scala_test = rule(
"main_class": attr.string(default="org.scalatest.tools.Runner"),
"suites": attr.string_list(),
"_scalatest": attr.label(executable=True, default=Label("@scalatest//file"), single_file=True, allow_files=True),
"_scalatest_reporter": attr.label(default=Label("//scala/support:test_reporter")),
} + _implicit_deps + _common_attrs,
outputs={
"jar": "%{name}_deploy.jar",
Expand Down
7 changes: 7 additions & 0 deletions scala/support/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
load("//scala:scala.bzl", "scala_library")

scala_library(name = "test_reporter",
srcs = ["JUnitXmlReporter.scala"],
deps = ["@scalatest//file"],
visibility = ["//visibility:public"],
)
Loading

0 comments on commit 470910a

Please sign in to comment.