test(compiler-cli): expand logging when extra compliance check fails (#39863)

Previously this would have just printed that `false` was not equal to
`true`, which, although true, is not very helpful. This commit adds
details about which special check failed together with the generated
code, for easier debugging.

PR Close #39863
This commit is contained in:
JoostK 2020-11-26 23:38:08 +01:00 committed by Jessica Janiuk
parent e2040af412
commit 157d690704
1 changed files with 5 additions and 1 deletions

View File

@ -79,6 +79,10 @@ function runExtraChecks(
`Unknown extra-check function: "${fnName}" in ${testPath}.\n` + `Unknown extra-check function: "${fnName}" in ${testPath}.\n` +
`Possible choices are: ${Object.keys(EXTRA_CHECK_FUNCTIONS).map(f => `\n - ${f}`)}.`); `Possible choices are: ${Object.keys(EXTRA_CHECK_FUNCTIONS).map(f => `\n - ${f}`)}.`);
} }
expect(fn(generated, ...args)).toBe(true); if (!fn(generated, ...args)) {
throw new Error(
`Extra check ${fnName}(${args.map(arg => JSON.stringify(arg)).join(',')}) in ${
testPath} failed for generated code:\n\n${generated}`);
}
} }
} }