Skip to content

Commit 3c608e0

Browse files
committed
Merge pull request #7 from bazelbuild/johnynek/automatic_test_discovery
deprecate scala_test suites
2 parents b169954 + a53afe0 commit 3c608e0

File tree

3 files changed

+10
-17
lines changed

3 files changed

+10
-17
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@ scala_test(name, srcs, suites, deps, data, main_class, resources, scalacopts, jv
277277
using the `scalatest` library. It may depend on `scala_library`,
278278
`scala_macro_library` and `java_library` rules.
279279

280-
A `scala_test` requires a `suites` attribute, specifying the fully qualified
281-
(canonical) names of the test suites to run. In a future version, we might
282-
investigate lifting this requirement.
280+
A `scala_test` by default runs all tests in a given target.
281+
For backwards compatiblity it accepts a `suites` attribute which
282+
is ignored due to the ease with which that field is not correctly
283+
populated and tests are not run.

scala/scala.bzl

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -145,23 +145,19 @@ cd $0.runfiles
145145
output=ctx.outputs.executable,
146146
content=content)
147147

148-
def _args_for_suites(suites):
149-
args = ["-o"]
150-
for suite in suites:
151-
args.extend(["-s", suite])
152-
return args
153-
154148
def _write_test_launcher(ctx, jars):
149+
if len(ctx.attr.suites) != 0:
150+
print("suites attribute is deprecated. All scalatest test suites are run")
151+
155152
content = """#!/bin/bash
156153
cd $0.runfiles
157154
{java} -cp {cp} {name} {args} "$@"
158155
"""
159156
content = content.format(
160157
java=ctx.file._java.path,
158+
cp=":".join([j.short_path for j in jars]),
161159
name=ctx.attr.main_class,
162-
args=' '.join(_args_for_suites(ctx.attr.suites)),
163-
deploy_jar=ctx.outputs.jar.path,
164-
cp=":".join([j.short_path for j in jars]))
160+
args="-R \"{path}\" -oWDF".format(path=ctx.outputs.jar.short_path))
165161
ctx.file_action(
166162
output=ctx.outputs.executable,
167163
content=content)
@@ -319,7 +315,7 @@ scala_test = rule(
319315
implementation=_scala_test_impl,
320316
attrs={
321317
"main_class": attr.string(default="org.scalatest.tools.Runner"),
322-
"suites": attr.string_list(non_empty=True, mandatory=True),
318+
"suites": attr.string_list(),
323319
"_scalatest": attr.label(executable=True, default=Label("@scalatest//file"), single_file=True, allow_files=True),
324320
"_java": attr.label(executable=True, default=Label("@bazel_tools//tools/jdk:java"), single_file=True, allow_files=True),
325321
} + _implicit_deps + _common_attrs,

test/BUILD

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,6 @@ scala_test(
3838
name = "HelloLibTest",
3939
size = "small", # Not a macro, can pass test-specific attributes.
4040
srcs = ["HelloLibTest.scala"],
41-
suites = [
42-
"scala.test.ScalaSuite",
43-
"scala.test.JavaSuite",
44-
],
4541
deps = [
4642
":HelloLib",
4743
],

0 commit comments

Comments
 (0)