Skip to content

Commit

Permalink
fix: assert_contains does not print anything when content is different.
Browse files Browse the repository at this point in the history
This fixes an issue where the test output is empty when there's difference.
  • Loading branch information
thesayyn committed May 3, 2024
1 parent 977f27f commit ab365cc
Showing 1 changed file with 4 additions and 17 deletions.
21 changes: 4 additions & 17 deletions lib/testing.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ def assert_contains(name, actual, expected, size = None, timeout = None, **kwarg
timeout: the timeout attribute of the test target
**kwargs: additional named arguments for the resulting sh_test
"""

test_sh = "_{}_test.sh".format(name)
expected_file = "_{}_expected.txt".format(name)

write_file(
Expand All @@ -30,23 +28,12 @@ def assert_contains(name, actual, expected, size = None, timeout = None, **kwarg
content = [expected],
)

write_file(
name = "_" + name,
out = test_sh,
content = [
"#!/usr/bin/env bash",
"set -o errexit",
"grep --fixed-strings -f $1 $2",
],
)

native.sh_test(
diff_test(
name = name,
srcs = [test_sh],
args = ["$(rootpath %s)" % expected_file, "$(rootpath %s)" % actual],
size = size,
file1 = expected_file,
file2 = actual,
timeout = default_timeout(size, timeout),
data = [actual, expected_file],
size = size,
**kwargs
)

Expand Down

0 comments on commit ab365cc

Please sign in to comment.