fix(ivy): change symbol-extractor to use .accept rather than -—define UPDATE_GOLDEN=1 (#22913)
Using `-—define` causes bazel to bust the cache which means that doing `bazel test target` followed by `bazel run -—define UPDATE_GOLDEN=1 target` will cause caches to be invalidated and house full rebuild. PR Close #22913
This commit is contained in:
parent
c84817970e
commit
bfe35dac85
@ -5,7 +5,6 @@ load("@build_bazel_rules_nodejs//:defs.bzl", "jasmine_node_test")
|
|||||||
|
|
||||||
ts_library(
|
ts_library(
|
||||||
name = "lib",
|
name = "lib",
|
||||||
testonly = 1,
|
|
||||||
srcs = glob(
|
srcs = glob(
|
||||||
["**/*.ts"],
|
["**/*.ts"],
|
||||||
exclude = [
|
exclude = [
|
||||||
|
@ -10,14 +10,9 @@ import * as fs from 'fs';
|
|||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import {SymbolExtractor} from './symbol_extractor';
|
import {SymbolExtractor} from './symbol_extractor';
|
||||||
|
|
||||||
// These keys are arbitrary and local to this test.
|
|
||||||
const update_var = 'UPDATE_GOLDEN';
|
|
||||||
const update_val = 1;
|
|
||||||
|
|
||||||
if (require.main === module) {
|
if (require.main === module) {
|
||||||
const doUpdate = process.env[update_var] == update_val;
|
|
||||||
const args = process.argv.slice(2) as[string, string];
|
const args = process.argv.slice(2) as[string, string];
|
||||||
process.exitCode = main(args, doUpdate) ? 0 : 1;
|
process.exitCode = main(args) ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -27,9 +22,10 @@ if (require.main === module) {
|
|||||||
* cli javascriptFilePath.js goldenFilePath.json
|
* cli javascriptFilePath.js goldenFilePath.json
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
function main(argv: [string, string], doUpdate: boolean): boolean {
|
function main(argv: [string, string, string] | [string, string]): boolean {
|
||||||
const javascriptFilePath = require.resolve(argv[0]);
|
const javascriptFilePath = require.resolve(argv[0]);
|
||||||
const goldenFilePath = require.resolve(argv[1]);
|
const goldenFilePath = require.resolve(argv[1]);
|
||||||
|
const doUpdate = argv[2] == '--accept';
|
||||||
|
|
||||||
const javascriptContent = fs.readFileSync(javascriptFilePath).toString();
|
const javascriptContent = fs.readFileSync(javascriptFilePath).toString();
|
||||||
const goldenContent = fs.readFileSync(goldenFilePath).toString();
|
const goldenContent = fs.readFileSync(goldenFilePath).toString();
|
||||||
@ -46,8 +42,7 @@ function main(argv: [string, string], doUpdate: boolean): boolean {
|
|||||||
if (!passed) {
|
if (!passed) {
|
||||||
console.error(`TEST FAILED!`);
|
console.error(`TEST FAILED!`);
|
||||||
console.error(` To update the golden file run: `);
|
console.error(` To update the golden file run: `);
|
||||||
console.error(
|
console.error(` bazel run ${process.env['BAZEL_TARGET']}.accept`);
|
||||||
` bazel run --define ${update_var}=${update_val} ${process.env['BAZEL_TARGET']}`);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return passed;
|
return passed;
|
||||||
|
@ -6,9 +6,13 @@
|
|||||||
"""This test verifies that a set of top level symbols from a javascript file match a gold file.
|
"""This test verifies that a set of top level symbols from a javascript file match a gold file.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_test")
|
# This does a deep import under //internal because of not wanting the wrapper macro
|
||||||
|
# because it introduces an extra target_bin target.
|
||||||
|
load("@build_bazel_rules_nodejs//internal/node:node.bzl", "nodejs_test", "nodejs_binary")
|
||||||
|
|
||||||
def js_expected_symbol_test(name, src, golden, **kwargs):
|
def js_expected_symbol_test(name, src, golden, **kwargs):
|
||||||
|
"""This test verifies that a set of top level symbols from a javascript file match a gold file.
|
||||||
|
"""
|
||||||
all_data = [src, golden]
|
all_data = [src, golden]
|
||||||
all_data += [Label("//tools/symbol-extractor:lib")]
|
all_data += [Label("//tools/symbol-extractor:lib")]
|
||||||
entry_point = "angular/tools/symbol-extractor/cli.js"
|
entry_point = "angular/tools/symbol-extractor/cli.js"
|
||||||
@ -20,3 +24,11 @@ def js_expected_symbol_test(name, src, golden, **kwargs):
|
|||||||
templated_args = ["$(location %s)" % src, "$(location %s)" % golden],
|
templated_args = ["$(location %s)" % src, "$(location %s)" % golden],
|
||||||
**kwargs
|
**kwargs
|
||||||
)
|
)
|
||||||
|
|
||||||
|
nodejs_binary(
|
||||||
|
name = name + '.accept',
|
||||||
|
data = all_data,
|
||||||
|
entry_point = entry_point,
|
||||||
|
templated_args = ["$(location %s)" % src, "$(location %s)" % golden, '--accept'],
|
||||||
|
**kwargs
|
||||||
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user