Skip to content

Commit

Permalink
Windows: fix tests for native test wrapper (#129)
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
ngiloq6 authored Mar 26, 2019
1 parent 5d0428e commit 49b7015
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 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_args_test_gen", "shell_test_suite")
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 @@ -84,3 +84,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"],
)
18 changes: 7 additions & 11 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,16 @@ 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))
out = ctx.actions.declare_file(ctx.label.name + ".sh")
ctx.actions.write(
output = script_file,
output = out,
content = script_content,
is_executable = True,
)
return [
DefaultInfo(executable = script_file),
]
return [DefaultInfo(files = depset([out]))]

shell_spawn_e2e_test = rule(
test = True,
implementation = _shell_spawn_e2e_test_impl,
shell_args_test_gen = rule(
implementation = _shell_args_test_gen_impl,
)

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

0 comments on commit 49b7015

Please sign in to comment.