forked from bazelbuild/rules_scala
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtesting.bzl
78 lines (70 loc) · 2.28 KB
/
testing.bzl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
load("@io_bazel_rules_scala//scala:providers.bzl", "declare_deps_provider")
load("@io_bazel_rules_scala//testing/toolchain:toolchain.bzl", "scala_testing_toolchain")
load("//scala:scala_cross_version.bzl", "version_suffix")
load("@io_bazel_rules_scala_config//:config.bzl", "SCALA_VERSION")
def _declare_deps_provider(macro_name, deps_id, deps, visibility):
label = "%s_%s_provider" % (macro_name, deps_id)
declare_deps_provider(
name = label,
deps_id = deps_id,
visibility = visibility,
deps = deps,
)
return label
def setup_scala_testing_toolchain(
name,
scala_version = SCALA_VERSION,
junit_classpath = None,
specs2_classpath = None,
specs2_junit_classpath = None,
scalatest_classpath = None,
visibility = ["//visibility:public"]):
dep_providers = []
if junit_classpath != None:
dep_providers.append(
_declare_deps_provider(
name,
"junit_classpath",
junit_classpath,
visibility,
),
)
if specs2_junit_classpath != None:
dep_providers.append(
_declare_deps_provider(
name,
"specs2_junit_classpath",
specs2_junit_classpath,
visibility,
),
)
if specs2_classpath != None:
dep_providers.append(
_declare_deps_provider(
name,
"specs2_classpath",
specs2_classpath,
visibility,
),
)
if scalatest_classpath != None:
dep_providers.append(
_declare_deps_provider(
name,
"scalatest_classpath",
scalatest_classpath,
visibility,
),
)
scala_testing_toolchain(
name = name + "_impl",
dep_providers = dep_providers,
visibility = visibility,
)
native.toolchain(
name = name,
toolchain = ":" + name + "_impl",
toolchain_type = "@io_bazel_rules_scala//testing/toolchain:testing_toolchain_type",
target_settings = ["@io_bazel_rules_scala_config//:scala_version" + version_suffix(scala_version)],
visibility = visibility,
)