Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make generated_file_test .update's visibility same as test rule #2677

Merged
merged 3 commits into from
May 17, 2021
Merged
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
5 changes: 4 additions & 1 deletion internal/generated_file_test/generated_file_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

load("@build_bazel_rules_nodejs//internal/node:node.bzl", "nodejs_binary", "nodejs_test")

def generated_file_test(name, generated, src, substring_search = False, src_dbg = None, **kwargs):
def generated_file_test(name, generated, src, substring_search = False, src_dbg = None, visibility = None, **kwargs):
"""Tests that a file generated by Bazel has identical content to a file in the workspace.

This is useful for testing, where a "snapshot" or "golden" file is checked in,
Expand All @@ -16,6 +16,7 @@ def generated_file_test(name, generated, src, substring_search = False, src_dbg
anywhere within the generated file. Note that the .update rule is not generated in substring mode.
src_dbg: if the build uses `--compilation_mode dbg` then some rules will produce different output.
In this case you can specify what the dbg version of the output should look like
visibility: visibility for both test target & update target
**kwargs: extra arguments passed to the underlying nodejs_test
"""
data = [src, generated]
Expand All @@ -36,6 +37,7 @@ def generated_file_test(name, generated, src, substring_search = False, src_dbg
loc % generated,
],
data = data,
visibility = visibility,
**kwargs
)

Expand All @@ -46,4 +48,5 @@ def generated_file_test(name, generated, src, substring_search = False, src_dbg
entry_point = "@build_bazel_rules_nodejs//internal/generated_file_test:bundle.js",
templated_args = ["--out", loc % src, loc % src_dbg, loc % generated],
data = data,
visibility = visibility,
)