2
0
Fork 0
mirror of https://github.com/bazel-contrib/bazel-lib synced 2024-11-26 13:30:30 +00:00

fix: assert_contains does not print anything when content is different.

This fixes an issue where the test output is empty when there's difference.
This commit is contained in:
Sahin Yort 2024-05-02 20:28:51 -07:00 committed by GitHub
parent 977f27f7a0
commit ab365ccd8d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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(
@ -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
)