diff --git a/.github/BUILD.bazel b/.github/BUILD.bazel index 86fecd7a80..0ed9b0df85 100644 --- a/.github/BUILD.bazel +++ b/.github/BUILD.bazel @@ -1,4 +1,4 @@ -load("@build_bazel_rules_nodejs//internal/golden_file_test:golden_file_test.bzl", "golden_file_test") +load("@build_bazel_rules_nodejs//:index.bzl", "generated_file_test") load("@rules_codeowners//tools:codeowners.bzl", "generate_codeowners") generate_codeowners( @@ -14,8 +14,8 @@ generate_codeowners( ], ) -golden_file_test( +generated_file_test( name = "codeowners", - actual = "gen_codeowners", - golden = "CODEOWNERS", + src = "CODEOWNERS", + generated = "gen_codeowners", ) diff --git a/BUILD.bazel b/BUILD.bazel index a56e2b873d..2974d7e70c 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -38,6 +38,7 @@ bzl_library( visibility = ["//visibility:public"], deps = [ "//internal/common:bzl", + "//internal/generated_file_test:bzl", "//internal/linker:bzl", "//internal/pkg_npm:bzl", "//internal/pkg_web:bzl", @@ -78,7 +79,7 @@ pkg_npm( "//internal/common:package_contents", "//internal/copy_repository:package_contents", "//internal/coverage:package_contents", - "//internal/golden_file_test:package_contents", + "//internal/generated_file_test:package_contents", "//internal/js_library:package_contents", "//internal/linker:package_contents", "//internal/node:package_contents", diff --git a/index.bzl b/index.bzl index 375b74535c..f0d456c558 100644 --- a/index.bzl +++ b/index.bzl @@ -22,6 +22,7 @@ load("//internal/common:check_bazel_version.bzl", _check_bazel_version = "check_ load("//internal/common:check_version.bzl", "check_version") load("//internal/common:copy_to_bin.bzl", _copy_to_bin = "copy_to_bin") load("//internal/common:params_file.bzl", _params_file = "params_file") +load("//internal/generated_file_test:generated_file_test.bzl", _generated_file_test = "generated_file_test") load( "//internal/node:node.bzl", _nodejs_binary = "nodejs_binary", @@ -42,6 +43,7 @@ npm_package_bin = _npm_bin pkg_web = _pkg_web copy_to_bin = _copy_to_bin params_file = _params_file +generated_file_test = _generated_file_test # ANY RULES ADDED HERE SHOULD BE DOCUMENTED, see index.for_docs.bzl # Allows us to avoid a transitive dependency on bazel_skylib from leaking to users diff --git a/index.for_docs.bzl b/index.for_docs.bzl index 7fc18e029f..9b4a7dd21e 100644 --- a/index.for_docs.bzl +++ b/index.for_docs.bzl @@ -19,6 +19,7 @@ This differs from :index.bzl because we don't have wrapping macros that hide the load("//internal/common:check_bazel_version.bzl", _check_bazel_version = "check_bazel_version") load("//internal/common:copy_to_bin.bzl", _copy_to_bin = "copy_to_bin") load("//internal/common:params_file.bzl", _params_file = "params_file") +load("//internal/generated_file_test:generated_file_test.bzl", _generated_file_test = "generated_file_test") load("//internal/node:node.bzl", _nodejs_binary = "nodejs_binary", _nodejs_test = "nodejs_test") load("//internal/node:node_repositories.bzl", _node_repositories = "node_repositories_rule") load("//internal/node:npm_package_bin.bzl", _npm_bin = "npm_package_bin") @@ -37,4 +38,5 @@ npm_install = _npm_install yarn_install = _yarn_install npm_package_bin = _npm_bin pkg_web = _pkg_web +generated_file_test = _generated_file_test # ANY RULES ADDED HERE SHOULD BE DOCUMENTED, run yarn stardoc to verify diff --git a/internal/generated_file_test/BUILD.bazel b/internal/generated_file_test/BUILD.bazel new file mode 100644 index 0000000000..40d131da5c --- /dev/null +++ b/internal/generated_file_test/BUILD.bazel @@ -0,0 +1,16 @@ +load("@bazel_skylib//:bzl_library.bzl", "bzl_library") + +package(default_visibility = ["//visibility:public"]) + +bzl_library( + name = "bzl", + srcs = glob(["*.bzl"]), + visibility = ["//visibility:public"], +) + +exports_files(["bin.js"]) + +filegroup( + name = "package_contents", + srcs = glob(["*"]), +) diff --git a/internal/generated_file_test/bin.js b/internal/generated_file_test/bin.js new file mode 100644 index 0000000000..8991c540f7 --- /dev/null +++ b/internal/generated_file_test/bin.js @@ -0,0 +1,48 @@ +const fs = require('fs'); +const path = require('path'); +const runfiles = require(process.env['BAZEL_NODE_RUNFILES_HELPER']); + +function main(args) { + const [mode, golden_no_debug, golden_debug, actual] = args; + const actualPath = runfiles.resolveWorkspaceRelative(actual); + const debugBuild = /\/bazel-out\/[^/\s]*-dbg\//.test(actualPath); + const golden = debugBuild ? golden_debug : golden_no_debug; + const actualContents = fs.readFileSync(actualPath, 'utf-8').replace(/\r\n/g, '\n'); + const goldenContents = + fs.readFileSync(runfiles.resolveWorkspaceRelative(golden), 'utf-8').replace(/\r\n/g, '\n'); + + if (actualContents === goldenContents) { + return 0; + } + if (mode === '--out') { + // Write to golden file + fs.writeFileSync(runfiles.resolveWorkspaceRelative(golden), actualContents); + console.error(`Replaced ${path.join(process.cwd(), golden)}`); + return 0; + } + if (mode === '--verify') { + const unidiff = require('unidiff'); + // Generated does not match golden + const diff = unidiff.diffLines(goldenContents, actualContents); + let prettyDiff = + unidiff.formatLines(diff, {aname: `[workspace]/${golden}`, bname: `[bazel-out]/${actual}`}); + if (prettyDiff.length > 5000) { + prettyDiff = prettyDiff.substr(0, 5000) + '/n...elided...'; + } + console.error(`Generated output doesn't match: + +${prettyDiff} + +If the bazel-out content is correct, you can update the workspace file by running: + + bazel run ${debugBuild ? '--compilation_mode=dbg ' : ''}${ + process.env['TEST_TARGET'].replace(/_bin$/, '')}.update +`); + return 1; + } + throw new Error('unknown mode', mode); +} + +if (require.main === module) { + process.exitCode = main(process.argv.slice(2)); +} diff --git a/internal/generated_file_test/generated_file_test.bzl b/internal/generated_file_test/generated_file_test.bzl new file mode 100644 index 0000000000..534e8db699 --- /dev/null +++ b/internal/generated_file_test/generated_file_test.bzl @@ -0,0 +1,42 @@ +"Convenience for testing that an output matches a file" + +load("@build_bazel_rules_nodejs//internal/node:node.bzl", "nodejs_binary", "nodejs_test") + +def generated_file_test(name, generated, src, src_dbg = 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, + so that you can code review changes to the generated output. + + Args: + name: Name of the rule. + generated: a Label of the output file generated by another rule + src: Label of the source file in the workspace + 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 + **kwargs: extra arguments passed to the underlying nodejs_test or nodejs_binary + """ + data = [src, generated, "@npm//unidiff"] + + if src_dbg: + data.append(src_dbg) + else: + src_dbg = src + + loc = "$(rootpath %s)" + nodejs_test( + name = name, + entry_point = "@build_bazel_rules_nodejs//internal/generated_file_test:bin.js", + templated_args = ["--verify", loc % src, loc % src_dbg, loc % generated], + data = data, + **kwargs + ) + + nodejs_binary( + name = name + ".update", + testonly = True, + entry_point = "@build_bazel_rules_nodejs//internal/generated_file_test:bin.js", + templated_args = ["--out", loc % src, loc % src_dbg, loc % generated], + data = data, + **kwargs + ) diff --git a/internal/golden_file_test/BUILD.bazel b/internal/golden_file_test/BUILD.bazel deleted file mode 100644 index df711b8cee..0000000000 --- a/internal/golden_file_test/BUILD.bazel +++ /dev/null @@ -1,8 +0,0 @@ -package(default_visibility = ["//visibility:public"]) - -exports_files(["bin.js"]) - -filegroup( - name = "package_contents", - srcs = glob(["*"]), -) diff --git a/internal/golden_file_test/bin.js b/internal/golden_file_test/bin.js deleted file mode 100644 index ee01f855b4..0000000000 --- a/internal/golden_file_test/bin.js +++ /dev/null @@ -1,44 +0,0 @@ -const fs = require('fs'); -const path = require('path'); -const runfiles = require(process.env['BAZEL_NODE_RUNFILES_HELPER']); - -function main(args) { - const [mode, golden_no_debug, golden_debug, actual] = args; - const actualPath = runfiles.resolveWorkspaceRelative(actual); - const debugBuild = /\/bazel-out\/[^/\s]*-dbg\//.test(actualPath); - const golden = debugBuild ? golden_debug : golden_no_debug; - const actualContents = fs.readFileSync(actualPath, 'utf-8').replace(/\r\n/g, '\n'); - const goldenContents = - fs.readFileSync(runfiles.resolveWorkspaceRelative(golden), 'utf-8').replace(/\r\n/g, '\n'); - - if (actualContents !== goldenContents) { - if (mode === '--out') { - // Write to golden file - fs.writeFileSync(runfiles.resolveWorkspaceRelative(golden), actualContents); - console.error(`Replaced ${path.join(process.cwd(), golden)}`); - } else if (mode === '--verify') { - const unidiff = require('unidiff'); - // Generated does not match golden - const diff = unidiff.diffLines(goldenContents, actualContents); - let prettyDiff = unidiff.formatLines(diff, {aname: golden, bname: actual}); - if (prettyDiff.length > 5000) { - prettyDiff = prettyDiff.substr(0, 5000) + '/n...elided...'; - } - throw new Error(`Actual output doesn't match golden file: - -${prettyDiff} - -Update the golden file: - - bazel run ${debugBuild ? '--compilation_mode=dbg ' : ''}${ - process.env['TEST_TARGET'].replace(/_bin$/, '')}.accept -`); - } else { - throw new Error('unknown mode', mode); - } - } -} - -if (require.main === module) { - main(process.argv.slice(2)); -} diff --git a/internal/golden_file_test/golden_file_test.bzl b/internal/golden_file_test/golden_file_test.bzl deleted file mode 100644 index d0543818f6..0000000000 --- a/internal/golden_file_test/golden_file_test.bzl +++ /dev/null @@ -1,34 +0,0 @@ -"Convenience for testing that an output matches a file" - -load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary", "nodejs_test") - -def golden_file_test(name, golden, actual, **kwargs): - """Tests an actual output against a golden output. - -Use `golden_debug` if the actual output changes when DEBUG is set. -""" - data = [golden, actual, "@npm//unidiff"] - - golden_debug = kwargs.pop("golden_debug", []) - if golden_debug: - data.extend([golden_debug]) - else: - golden_debug = golden - - loc = "$(rootpath %s)" - nodejs_test( - name = name, - entry_point = "@build_bazel_rules_nodejs//internal/golden_file_test:bin.js", - templated_args = ["--verify", loc % golden, loc % golden_debug, loc % actual], - data = data, - **kwargs - ) - - nodejs_binary( - name = name + ".accept", - testonly = True, - entry_point = "@build_bazel_rules_nodejs//internal/golden_file_test:bin.js", - templated_args = ["--out", loc % golden, loc % golden_debug, loc % actual], - data = data, - **kwargs - ) diff --git a/internal/linker/BUILD.bazel b/internal/linker/BUILD.bazel index c8fd38051c..3cdd4d684b 100644 --- a/internal/linker/BUILD.bazel +++ b/internal/linker/BUILD.bazel @@ -6,7 +6,7 @@ load("//packages/typescript:checked_in_ts_project.bzl", "checked_in_ts_project") # because the implementation of ts_library depends on the linker so that would be a cycle. # So we compile it to JS and check in the result as index.js. # To update index.js run: -# bazel run //internal/linker:linker_lib_check_compiled.accept +# bazel run //internal/linker:linker_lib_check_compiled.update checked_in_ts_project( name = "linker_lib", src = "link_node_modules.ts", diff --git a/internal/linker/test/integration/BUILD.bazel b/internal/linker/test/integration/BUILD.bazel index 503ca8e57c..158dfd3b25 100644 --- a/internal/linker/test/integration/BUILD.bazel +++ b/internal/linker/test/integration/BUILD.bazel @@ -1,4 +1,4 @@ -load("@build_bazel_rules_nodejs//internal/golden_file_test:golden_file_test.bzl", "golden_file_test") +load("@build_bazel_rules_nodejs//:index.bzl", "generated_file_test") load(":rule.bzl", "linked") # Use the node binary supplied by the bazel toolchain @@ -130,23 +130,23 @@ linked( ], ) -golden_file_test( +generated_file_test( # default rule in this package name = "integration", - actual = "actual", - golden = "golden.txt", + src = "golden.txt", + generated = "actual", ) -golden_file_test( +generated_file_test( # default rule in this package name = "integration_conflicts", - actual = "actual_with_conflicts", - golden = "golden.txt", + src = "golden.txt", + generated = "actual_with_conflicts", ) -golden_file_test( +generated_file_test( # default rule in this package name = "integration_conflicts_alt", - actual = "actual_with_conflicts_alt", - golden = "golden.txt", + src = "golden.txt", + generated = "actual_with_conflicts_alt", ) diff --git a/internal/node/BUILD.bazel b/internal/node/BUILD.bazel index c35e61a1b7..f739ff9d0a 100644 --- a/internal/node/BUILD.bazel +++ b/internal/node/BUILD.bazel @@ -13,7 +13,7 @@ # limitations under the License. load("@bazel_skylib//:bzl_library.bzl", "bzl_library") -load("//internal/golden_file_test:golden_file_test.bzl", "golden_file_test") +load("@build_bazel_rules_nodejs//:index.bzl", "generated_file_test") package(default_visibility = ["//visibility:public"]) @@ -47,9 +47,9 @@ filegroup( ) # To update node_patches.js run: -# bazel run //internal/node:checked_in_node_patches.accept -golden_file_test( +# bazel run //internal/node:checked_in_node_patches.update +generated_file_test( name = "checked_in_node_patches", - actual = "//packages/node-patches:bundle", - golden = "node_patches.js", + src = "node_patches.js", + generated = "//packages/node-patches:bundle", ) diff --git a/internal/node/test/BUILD.bazel b/internal/node/test/BUILD.bazel index 073155a732..b1d1d42120 100644 --- a/internal/node/test/BUILD.bazel +++ b/internal/node/test/BUILD.bazel @@ -1,5 +1,4 @@ -load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary", "nodejs_test", "npm_package_bin") -load("@build_bazel_rules_nodejs//internal/golden_file_test:golden_file_test.bzl", "golden_file_test") +load("@build_bazel_rules_nodejs//:index.bzl", "generated_file_test", "nodejs_binary", "nodejs_test", "npm_package_bin") load("@npm//typescript:index.bzl", "tsc") load("//internal/js_library:js_library.bzl", "js_library") load("//internal/node:node_repositories.bzl", "BUILT_IN_NODE_PLATFORMS") @@ -358,10 +357,10 @@ npm_package_bin( tool = ":test_runfiles_helper", ) -golden_file_test( +generated_file_test( name = "test_runfiles_helper_test", - actual = ":test_runfiles_helper.out", - golden = "test_runfiles_helper.golden", + src = "test_runfiles_helper.golden", + generated = ":test_runfiles_helper.out", ) nodejs_test( diff --git a/internal/npm_install/test/BUILD.bazel b/internal/npm_install/test/BUILD.bazel index 0c02469053..32b5c34e68 100644 --- a/internal/npm_install/test/BUILD.bazel +++ b/internal/npm_install/test/BUILD.bazel @@ -20,7 +20,7 @@ jasmine_node_test( ) nodejs_binary( - name = "test.accept", + name = "test.update", data = [ ":check.js", ":goldens", diff --git a/internal/npm_install/test/check.js b/internal/npm_install/test/check.js index c33ae79b13..72bf73b21a 100644 --- a/internal/npm_install/test/check.js +++ b/internal/npm_install/test/check.js @@ -40,7 +40,7 @@ ${prettyDiff} Update the golden file: - bazel run ${process.env['TEST_TARGET']}.accept`); + bazel run ${process.env['TEST_TARGET']}.update`); } } } diff --git a/packages/rollup/test/integration/BUILD.bazel b/packages/rollup/test/integration/BUILD.bazel index c91df3de01..ac0df8515d 100644 --- a/packages/rollup/test/integration/BUILD.bazel +++ b/packages/rollup/test/integration/BUILD.bazel @@ -1,5 +1,4 @@ -load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary", "npm_package_bin") -load("@build_bazel_rules_nodejs//internal/golden_file_test:golden_file_test.bzl", "golden_file_test") +load("@build_bazel_rules_nodejs//:index.bzl", "generated_file_test", "nodejs_binary", "npm_package_bin") load("//packages/rollup:index.bzl", "rollup_bundle") _BUNDLE_FORMATS = [ @@ -42,13 +41,13 @@ _BUNDLE_FORMATS = [ # Verify the bundle .js files [ - golden_file_test( + generated_file_test( name = "test_%s" % format, - actual = "bundle.%s.js" % format, - golden = "//%s:golden.%s.js_" % ( + src = "//%s:golden.%s.js_" % ( package_name(), format, ), + generated = "bundle.%s.js" % format, ) for format in _BUNDLE_FORMATS ] @@ -82,10 +81,10 @@ nodejs_binary( ] [ - golden_file_test( + generated_file_test( name = "test_%s_map_sha256" % format, - actual = "bundle.%s.js.map.sha256" % format, - golden = ":golden.%s.js.map.sha256_" % format, + src = ":golden.%s.js.map.sha256_" % format, + generated = "bundle.%s.js.map.sha256" % format, # TODO: fix this test on Windows as sha256 differs tags = ["fix-windows"], ) @@ -111,10 +110,10 @@ npm_package_bin( tool = ":sha256", ) -golden_file_test( +generated_file_test( name = "test_umd_sha256", - actual = "bundle.umd.js.sha256", - golden = ":golden.umd.js.sha256_", + src = ":golden.umd.js.sha256_", + generated = "bundle.umd.js.sha256", # TODO: fix this test on Windows as sha256 differs tags = ["fix-windows"], ) diff --git a/packages/rollup/test/integration/accept.sh b/packages/rollup/test/integration/accept.sh index 01a9927ee1..528962f4bb 100755 --- a/packages/rollup/test/integration/accept.sh +++ b/packages/rollup/test/integration/accept.sh @@ -1,13 +1,13 @@ -bazel run //packages/rollup/test/integration:test_amd.accept -bazel run //packages/rollup/test/integration:test_cjs.accept -bazel run //packages/rollup/test/integration:test_esm.accept -bazel run //packages/rollup/test/integration:test_iife.accept -bazel run //packages/rollup/test/integration:test_system.accept -bazel run //packages/rollup/test/integration:test_umd.accept -bazel run //packages/rollup/test/integration:test_amd_map_sha256.accept -bazel run //packages/rollup/test/integration:test_cjs_map_sha256.accept -bazel run //packages/rollup/test/integration:test_esm_map_sha256.accept -bazel run //packages/rollup/test/integration:test_iife_map_sha256.accept -bazel run //packages/rollup/test/integration:test_system_map_sha256.accept -bazel run //packages/rollup/test/integration:test_umd_map_sha256.accept -bazel run //packages/rollup/test/integration:test_umd_sha256.accept +bazel run //packages/rollup/test/integration:test_amd.update +bazel run //packages/rollup/test/integration:test_cjs.update +bazel run //packages/rollup/test/integration:test_esm.update +bazel run //packages/rollup/test/integration:test_iife.update +bazel run //packages/rollup/test/integration:test_system.update +bazel run //packages/rollup/test/integration:test_umd.update +bazel run //packages/rollup/test/integration:test_amd_map_sha256.update +bazel run //packages/rollup/test/integration:test_cjs_map_sha256.update +bazel run //packages/rollup/test/integration:test_esm_map_sha256.update +bazel run //packages/rollup/test/integration:test_iife_map_sha256.update +bazel run //packages/rollup/test/integration:test_system_map_sha256.update +bazel run //packages/rollup/test/integration:test_umd_map_sha256.update +bazel run //packages/rollup/test/integration:test_umd_sha256.update diff --git a/packages/rollup/test/plugins/BUILD.bazel b/packages/rollup/test/plugins/BUILD.bazel index dfbf338f25..39e1b04a35 100644 --- a/packages/rollup/test/plugins/BUILD.bazel +++ b/packages/rollup/test/plugins/BUILD.bazel @@ -1,4 +1,4 @@ -load("@build_bazel_rules_nodejs//internal/golden_file_test:golden_file_test.bzl", "golden_file_test") +load("@build_bazel_rules_nodejs//:index.bzl", "generated_file_test") load("//packages/rollup:index.bzl", "rollup_bundle") rollup_bundle( @@ -11,8 +11,8 @@ rollup_bundle( deps = ["@npm//rollup-plugin-json"], ) -golden_file_test( +generated_file_test( name = "test", - actual = "plugins.js", - golden = "golden.js_", + src = "golden.js_", + generated = "plugins.js", ) diff --git a/packages/rollup/test/version_stamp/BUILD.bazel b/packages/rollup/test/version_stamp/BUILD.bazel index 965a3e9c82..50189c1ed5 100644 --- a/packages/rollup/test/version_stamp/BUILD.bazel +++ b/packages/rollup/test/version_stamp/BUILD.bazel @@ -1,4 +1,4 @@ -load("@build_bazel_rules_nodejs//internal/golden_file_test:golden_file_test.bzl", "golden_file_test") +load("@build_bazel_rules_nodejs//:index.bzl", "generated_file_test") load("//internal/node:context.bzl", "node_context_data") load("//packages/rollup:index.bzl", "rollup_bundle") @@ -18,10 +18,10 @@ rollup_bundle( supports_workers = True, ) -golden_file_test( +generated_file_test( name = "test", + src = "golden.js_", # Leave off the ".js" extension to test that it's the default output - actual = "version_stamp", - golden = "golden.js_", - golden_debug = "golden_debug.js_", + generated = "version_stamp", + src_dbg = "golden_debug.js_", ) diff --git a/packages/terser/test/args/BUILD.bazel b/packages/terser/test/args/BUILD.bazel index 041fe8c1bd..8dcfd75454 100644 --- a/packages/terser/test/args/BUILD.bazel +++ b/packages/terser/test/args/BUILD.bazel @@ -1,4 +1,4 @@ -load("@build_bazel_rules_nodejs//internal/golden_file_test:golden_file_test.bzl", "golden_file_test") +load("@build_bazel_rules_nodejs//:index.bzl", "generated_file_test") load("//packages/terser:index.bzl", "terser_minified") terser_minified( @@ -8,9 +8,9 @@ terser_minified( sourcemap = False, ) -golden_file_test( +generated_file_test( name = "test", - actual = "out.min", - golden = "output.golden.js_", - golden_debug = "output.debug.golden.js_", + src = "output.golden.js_", + generated = "out.min", + src_dbg = "output.debug.golden.js_", ) diff --git a/packages/terser/test/debug/BUILD.bazel b/packages/terser/test/debug/BUILD.bazel index d5a4edddeb..d3f533001a 100644 --- a/packages/terser/test/debug/BUILD.bazel +++ b/packages/terser/test/debug/BUILD.bazel @@ -1,4 +1,4 @@ -load("@build_bazel_rules_nodejs//internal/golden_file_test:golden_file_test.bzl", "golden_file_test") +load("@build_bazel_rules_nodejs//:index.bzl", "generated_file_test") load("//packages/terser:index.bzl", "terser_minified") terser_minified( @@ -9,10 +9,10 @@ terser_minified( sourcemap = False, ) -golden_file_test( +generated_file_test( name = "test", - actual = "out.min", - golden = "output.debug.golden.js_", + src = "output.debug.golden.js_", + generated = "out.min", ) terser_minified( @@ -23,9 +23,9 @@ terser_minified( # Instead we'll run the test with --compilation_mode=dbg ) -golden_file_test( +generated_file_test( name = "test_define_DEBUG", - actual = "debug_from_env", - golden = "output.golden.js_", - golden_debug = "output.debug.golden.js_", + src = "output.golden.js_", + generated = "debug_from_env", + src_dbg = "output.debug.golden.js_", ) diff --git a/packages/terser/test/user_config/BUILD.bazel b/packages/terser/test/user_config/BUILD.bazel index d873a2f9f3..8b4ee61c09 100644 --- a/packages/terser/test/user_config/BUILD.bazel +++ b/packages/terser/test/user_config/BUILD.bazel @@ -1,4 +1,4 @@ -load("@build_bazel_rules_nodejs//internal/golden_file_test:golden_file_test.bzl", "golden_file_test") +load("@build_bazel_rules_nodejs//:index.bzl", "generated_file_test") load("//packages/terser:index.bzl", "terser_minified") terser_minified( @@ -8,9 +8,9 @@ terser_minified( sourcemap = False, ) -golden_file_test( +generated_file_test( name = "test", - actual = "out.min", - golden = "output.golden.js_", - golden_debug = "output.debug.golden.js_", + src = "output.golden.js_", + generated = "out.min", + src_dbg = "output.debug.golden.js_", ) diff --git a/packages/typescript/checked_in_ts_project.bzl b/packages/typescript/checked_in_ts_project.bzl index 55cc5ed66b..b904ce3319 100644 --- a/packages/typescript/checked_in_ts_project.bzl +++ b/packages/typescript/checked_in_ts_project.bzl @@ -1,6 +1,6 @@ "checked_in_ts_project rule" -load("@build_bazel_rules_nodejs//internal/golden_file_test:golden_file_test.bzl", "golden_file_test") +load("@build_bazel_rules_nodejs//:index.bzl", "generated_file_test") load("@build_bazel_rules_nodejs//third_party/github.com/bazelbuild/bazel-skylib:rules/write_file.bzl", "write_file") load("//packages/typescript:index.bzl", "ts_project") @@ -57,8 +57,8 @@ def checked_in_ts_project(name, src, checked_in_js = None, **kwargs): ) # Assert that we kept the index.js up-to-date when changing the TS code - golden_file_test( + generated_file_test( name = "%s_check_compiled" % name, - actual = "_%s_no_format.js" % name, - golden = checked_in_js, + generated = "_%s_no_format.js" % name, + src = checked_in_js, ) diff --git a/packages/typescript/test/ts_project/simple/BUILD.bazel b/packages/typescript/test/ts_project/simple/BUILD.bazel index caa8557a6a..7e31fe2090 100644 --- a/packages/typescript/test/ts_project/simple/BUILD.bazel +++ b/packages/typescript/test/ts_project/simple/BUILD.bazel @@ -1,13 +1,13 @@ -load("@build_bazel_rules_nodejs//internal/golden_file_test:golden_file_test.bzl", "golden_file_test") +load("@build_bazel_rules_nodejs//:index.bzl", "generated_file_test") load("//packages/typescript:index.bzl", "ts_project") # This uses defaults for all attributes. # It will find `index.ts` and produce `index.js` ts_project() -golden_file_test( +generated_file_test( name = "test", + src = "index.golden.js", # Refers to the output from ts_project above - actual = "index.js", - golden = "index.golden.js", + generated = "index.js", ) diff --git a/scripts/update_codeowners.sh b/scripts/update_codeowners.sh index 0c8c20172c..175b69d2f7 100755 --- a/scripts/update_codeowners.sh +++ b/scripts/update_codeowners.sh @@ -19,4 +19,4 @@ readonly new_owners=$( readonly command="set owners [$new_owners]|//.github:gen_codeowners" -echo $command | $BUILDOZER -f - && $BAZEL run //.github:codeowners.accept +echo $command | $BUILDOZER -f - && $BAZEL run //.github:codeowners.update