Skip to content

Commit

Permalink
test(builtin): fix golden_file_test that check compilation_mode=dbg o…
Browse files Browse the repository at this point in the history
…utputs

This test should not check COMPILATION_MODE since a test does not have a compilation_mode as all of the outputs have already been compiled. The test should determine if the output was debug/non-debug based on the bazel-out folder name of the file being checked.
  • Loading branch information
gregmagolan committed Jan 2, 2020
1 parent 9e0033d commit a453efe
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions internal/golden_file_test/bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ const path = require('path');

function main(args) {
const [mode, golden_no_debug, golden_debug, actual] = args;
const debug = process.env['COMPILATION_MODE'] === 'dbg';
const golden = debug ? golden_debug : golden_no_debug;
const actualContents = fs.readFileSync(require.resolve(actual), 'utf-8').replace(/\r\n/g, '\n');
const actualPath = require.resolve(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(require.resolve(golden), 'utf-8').replace(/\r\n/g, '\n');

if (actualContents !== goldenContents) {
Expand All @@ -27,7 +28,7 @@ ${prettyDiff}
Update the golden file:
bazel run ${debug ? '--compilation_mode=dbg ' : ''}${
bazel run ${debugBuild ? '--compilation_mode=dbg ' : ''}${
process.env['BAZEL_TARGET'].replace(/_bin$/, '')}.accept
`);
} else {
Expand Down

0 comments on commit a453efe

Please sign in to comment.