Skip to content

Commit

Permalink
fix: make generated_file_test .update's visibility same as test rule (
Browse files Browse the repository at this point in the history
  • Loading branch information
longlho authored May 17, 2021
1 parent 8319dbf commit 30bc86c
Showing 1 changed file with 4 additions and 1 deletion.
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,
)

0 comments on commit 30bc86c

Please sign in to comment.