Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion javascript/private/windows_tool.bzl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Windows launcher shim for js_binary build tools. Removal tracked in #13889 (bazel-lib#1296)."""
"""Windows launcher shim for js_binary build tools. Removal tracked in #13889 (bazel-lib#1296); `//typescript/tests:windows_tool_tests_upstream_launcher` fails once upstream fixes it."""

visibility(["//astro/...", "//javascript/...", "//typescript/..."])

Expand Down
28 changes: 28 additions & 0 deletions typescript/tests/windows_tool_tests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,32 @@ default_select_test = analysistest.make(
config_settings = {"//command_line_option:platforms": str(Label("//tools/platforms:linux_x86_64"))},
)

_UPSTREAM_CHANGED = "the upstream Windows js_binary launcher changed; check whether js_build_tool can be removed (#13889)"
_RLOCATION_START = ":: Start of rlocation"
_RLOCATION_END = ":: End of rlocation"

def _upstream_launcher_impl(ctx):
env = analysistest.begin(ctx)
executable = analysistest.target_under_test(env)[DefaultInfo].files_to_run.executable
asserts.equals(env, "tsc.bat", executable.basename, _UPSTREAM_CHANGED)
writes = [a for a in analysistest.target_actions(env) if a.mnemonic == "FileWrite" and executable in a.outputs.to_list()]
asserts.equals(env, 1, len(writes), _UPSTREAM_CHANGED)
if len(writes) != 1:
return analysistest.end(env)
content = writes[0].content
if _RLOCATION_START not in content or _RLOCATION_END not in content:
asserts.true(env, False, _UPSTREAM_CHANGED)
return analysistest.end(env)
body = content[:content.index(_RLOCATION_START)] + content[content.index(_RLOCATION_END):]
asserts.true(env, "if not exist \"!run_script!\" call :rlocation" in body, _UPSTREAM_CHANGED)
asserts.false(env, "RUNFILES_MANIFEST_FILE" in body, _UPSTREAM_CHANGED)
return analysistest.end(env)

upstream_launcher_test = analysistest.make(
_upstream_launcher_impl,
config_settings = {"//command_line_option:platforms": str(Label("//tools/platforms:windows_x86_64"))},
)

_CASES = [
("tsc", "//typescript/private:tsc", "@npm_typescript//:tsc"),
("vite", "//javascript/private:vite_build_tool", "//javascript/private:vite_tool"),
Expand Down Expand Up @@ -82,6 +108,8 @@ def windows_tool_tests(name):
)
default_select_test(name = prefix + "_default_select", target_under_test = alias, tool = tool, size = "small")
tests += [prefix + "_shim", prefix + "_windows_select", prefix + "_default_select"]
upstream_launcher_test(name = name + "_upstream_launcher", target_under_test = "@npm_typescript//:tsc", size = "small")
tests.append(name + "_upstream_launcher")
native.test_suite(name = name, tests = tests)

def ts_project_tool_tests(name, project):
Expand Down
Loading