Skip to content

Commit 1547510

Browse files
authored
fix: windows typecheck_test .sh vs .bat error (#732)
1 parent e852fc0 commit 1547510

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

ts/private/build_test.bzl

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,15 @@ It is used to force Bazel to build some of its dependencies, in the case where
1111
"""
1212

1313
def _build_test_impl(ctx):
14-
executable = ctx.actions.declare_file(ctx.label.name + ".sh")
14+
# See https://github.com/bazelbuild/bazel-skylib/blob/1.7.1/rules/build_test.bzl#L19-L33
1515

16+
extension = ".bat" if ctx.attr.is_windows else ".sh"
17+
content = "exit 0" if ctx.attr.is_windows else "#!/usr/bin/env bash\nexit 0"
18+
executable = ctx.actions.declare_file(ctx.label.name + extension)
1619
ctx.actions.write(
1720
output = executable,
1821
is_executable = True,
19-
content = "#!/usr/bin/env bash\nexit 0",
22+
content = content,
2023
)
2124

2225
return DefaultInfo(
@@ -26,11 +29,22 @@ def _build_test_impl(ctx):
2629
runfiles = ctx.runfiles(files = ctx.files.targets),
2730
)
2831

29-
build_test = rule(
32+
_build_test = rule(
3033
doc = _DOC,
3134
implementation = _build_test_impl,
3235
attrs = {
3336
"targets": attr.label_list(allow_files = True),
37+
"is_windows": attr.bool(mandatory = True),
3438
},
3539
test = True,
3640
)
41+
42+
def build_test(name, **kwargs):
43+
_build_test(
44+
name = name,
45+
is_windows = select({
46+
"@bazel_tools//src/conditions:host_windows": True,
47+
"//conditions:default": False,
48+
}),
49+
**kwargs
50+
)

0 commit comments

Comments
 (0)