-
Notifications
You must be signed in to change notification settings - Fork 6.8k
/
Copy pathdefaults2.bzl
101 lines (88 loc) · 3.16 KB
/
defaults2.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
load("@aspect_rules_jasmine//jasmine:defs.bzl", _jasmine_test = "jasmine_test")
load("//tools/bazel:ts_project_interop.bzl", _ts_project = "ts_project")
load("//tools/bazel:module_name.bzl", "compute_module_name")
load("@aspect_rules_js//npm:defs.bzl", _npm_package = "npm_package")
load("@rules_angular//src/ng_project:index.bzl", _ng_project = "ng_project")
load("@devinfra//bazel/spec-bundling:index_rjs.bzl", _spec_bundle = "spec_bundle")
load("@rules_browsers//src/wtr:index.bzl", "wtr_test")
load("@devinfra//bazel/http-server:index.bzl", _http_server = "http_server")
spec_bundle = _spec_bundle
http_server = _http_server
def npm_package(**kwargs):
_npm_package(**kwargs)
def ts_project(
name,
source_map = True,
testonly = False,
tsconfig = None,
**kwargs):
if tsconfig == None and native.package_name().startswith("src"):
tsconfig = "//src:test-tsconfig" if testonly else "//src:build-tsconfig"
_ts_project(
name,
source_map = source_map,
module_name = compute_module_name(testonly),
testonly = testonly,
tsconfig = tsconfig,
**kwargs
)
# TODO(devversion): Partner with ISE team to support `rules_js` here.
# if False and not testonly:
# _make_tsec_test(kwargs["name"])
def ng_project(
name,
source_map = True,
testonly = False,
tsconfig = None,
**kwargs):
if tsconfig == None and native.package_name().startswith("src"):
tsconfig = "//src:test-tsconfig" if testonly else "//src:build-tsconfig"
_ts_project(
name,
source_map = source_map,
module_name = compute_module_name(testonly),
rule_impl = _ng_project,
testonly = testonly,
tsconfig = tsconfig,
**kwargs
)
# TODO(devversion): Partner with ISE team to support `rules_js` here.
# if False and not testonly:
# _make_tsec_test(kwargs["name"])
def jasmine_test(name, data = [], args = [], **kwargs):
# Create relative path to root, from current package dir. Necessary as
# we change the `chdir` below to the package directory.
relative_to_root = "/".join([".."] * len(native.package_name().split("/")))
_jasmine_test(
name = name,
node_modules = "//:node_modules",
chdir = native.package_name(),
fixed_args = [
"--require=%s/node_modules/source-map-support/register.js" % relative_to_root,
"**/*spec.js",
"**/*spec.mjs",
"**/*spec.cjs",
] + args,
data = data + [
"//:node_modules/source-map-support",
],
**kwargs
)
def karma_web_test_suite(name, tags = [], deps = [], bootstrap = [], **kwargs):
spec_bundle(
name = "%s_bundle" % name,
srcs = ["//src:build-tsconfig"],
bootstrap = bootstrap,
deps = deps,
config = {
"resolveExtensions": [".js"],
"tsconfig": "./src/bazel-tsconfig-build.json",
},
)
test_tags = ["partial-compilation-integration"] + tags
wtr_test(
name = name,
deps = [":%s_bundle" % name],
tags = test_tags,
**kwargs
)