Skip to content

Commit

Permalink
Windows: fix tests for native test wrapper
Browse files Browse the repository at this point in the history
All tests work with
`--incompatible_windows_native_test_wrapper`
except for the ones already broken on Windows
(//tests:analysis_test_e2e_test and
//tests:unittest_e2e_test).

See bazelbuild/bazel#6622
  • Loading branch information
laszlocsomor committed Mar 18, 2019
1 parent f26e8ac commit ab9c042
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
11 changes: 10 additions & 1 deletion tests/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ load(":partial_tests.bzl", "partial_test_suite")
load(":paths_tests.bzl", "paths_test_suite")
load(":selects_tests.bzl", "selects_test_suite")
load(":sets_tests.bzl", "sets_test_suite")
load(":shell_tests.bzl", "shell_test_suite")
load(":shell_tests.bzl", "shell_test_suite", "shell_args_test_gen")
load(":structs_tests.bzl", "structs_test_suite")
load(":types_tests.bzl", "types_test_suite")
load(":unittest_tests.bzl", "unittest_passing_tests_suite")
Expand Down Expand Up @@ -73,3 +73,12 @@ sh_test(
],
tags = ["local"],
)

shell_args_test_gen(
name = "shell_spawn_e2e_test_src",
)

sh_test(
name = "shell_spawn_e2e_test",
srcs = [":shell_spawn_e2e_test_src"],
)
17 changes: 7 additions & 10 deletions tests/shell_tests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ def _shell_quote_test(ctx):

shell_quote_test = unittest.make(_shell_quote_test)

def _shell_spawn_e2e_test_impl(ctx):
"""Test spawning a real shell."""
def _shell_args_test_gen_impl(ctx):
"""Test argument escaping: this rule writes a script for a sh_test."""
args = [
"foo",
"foo bar",
Expand Down Expand Up @@ -83,19 +83,17 @@ def _shell_spawn_e2e_test_impl(ctx):
"line tab\tcharacter $foo qu\"o\"te it'\\''s foo\\bar back`echo q`uote'",
'[[ "${output}" == "${expected}" ]]',
])
script_file = ctx.actions.declare_file("%s.sh" % (ctx.label.name))
script_file = ctx.outputs.script
ctx.actions.write(
output = script_file,
content = script_content,
is_executable = True,
)
return [
DefaultInfo(executable = script_file),
]
return [DefaultInfo(files = depset([script_file]))]

shell_spawn_e2e_test = rule(
test = True,
implementation = _shell_spawn_e2e_test_impl,
shell_args_test_gen = rule(
implementation = _shell_args_test_gen_impl,
outputs = {"script": "%{name}.sh"},
)

def shell_test_suite():
Expand All @@ -104,5 +102,4 @@ def shell_test_suite():
"shell_tests",
shell_array_literal_test,
shell_quote_test,
shell_spawn_e2e_test,
)

0 comments on commit ab9c042

Please sign in to comment.