diff --git a/scala/scala.bzl b/scala/scala.bzl index 9d23ab07e..8f876908b 100644 --- a/scala/scala.bzl +++ b/scala/scala.bzl @@ -660,6 +660,17 @@ trap finish EXIT return _scala_binary_common(ctx, cjars, transitive_rjars, jars.transitive_compile_jars, jars.jars2labels) +def _scala_test_flags(ctx): + # output report test duration + flags = "-oD" + if ctx.attr.full_stacktraces: + flags += "F" + else: + flags += "S" + if not ctx.attr.colors: + flags += "W" + return flags + def _scala_test_impl(ctx): if len(ctx.attr.suites) != 0: print( @@ -684,7 +695,7 @@ def _scala_test_impl(ctx): args = " ".join([ "-R \"{path}\"".format(path=ctx.outputs.jar.short_path), - "-oWDS", + _scala_test_flags(ctx), "-C io.bazel.rules.scala.JUnitXmlReporter ", ]) # main_class almost has to be "org.scalatest.tools.Runner" due to args.... @@ -852,6 +863,8 @@ scala_test = rule( attrs={ "main_class": attr.string(default="io.bazel.rulesscala.scala_test.Runner"), "suites": attr.string_list(), + "colors": attr.bool(default=True), + "full_stacktraces": attr.bool(default=True), "_scalatest": attr.label(default=Label("//external:io_bazel_rules_scala/dependency/scalatest/scalatest"), allow_files=True), "_scalatest_runner": attr.label(executable=True, cfg="host", default=Label("//src/java/io/bazel/rulesscala/scala_test:runner.jar"), allow_files=True), "_scalatest_reporter": attr.label(default=Label("//scala/support:test_reporter")), @@ -987,11 +1000,12 @@ def _sanitize_string_for_usage(s): # This auto-generates a test suite based on the passed set of targets # we will add a root test_suite with the name of the passed name def scala_test_suite(name, srcs = [], deps = [], runtime_deps = [], data = [], resources = [], - scalacopts = [], jvm_flags = [], visibility = None, size = None): + scalacopts = [], jvm_flags = [], visibility = None, size = None, + colors=True, full_stacktraces=True): ts = [] for test_file in srcs: n = "%s_test_suite_%s" % (name, _sanitize_string_for_usage(test_file)) - scala_test(name = n, srcs = [test_file], deps = deps, runtime_deps = runtime_deps, resources=resources, scalacopts=scalacopts, jvm_flags=jvm_flags, visibility=visibility, size=size) + scala_test(name = n, srcs = [test_file], deps = deps, runtime_deps = runtime_deps, resources=resources, scalacopts=scalacopts, jvm_flags=jvm_flags, visibility=visibility, size=size, colors=colors, full_stacktraces=full_stacktraces) ts.append(n) native.test_suite(name = name, tests = ts, visibility = visibility)