test(compiler-cli): improve source mapping compliance test failure messages (#40237)

Now, if a source-mapping compliance test fails, the message displays both
the path to the generated file, and more helpfully the path to the expected
file.

PR Close #40237
This commit is contained in:
Pete Bacon Darwin 2020-12-29 15:17:10 +00:00 committed by atscott
parent 9f662e1313
commit dfe64a0060
2 changed files with 4 additions and 4 deletions

View File

@ -58,7 +58,7 @@ export function checkExpectations(
const generated = fs.readFile(generatedPath);
let expected = fs.readFile(expectedPath);
expected = replaceMacros(expected);
expected = checkMappings(fs, generated, generatedPath, expected);
expected = checkMappings(fs, generated, generatedPath, expected, expectedPath);
expectEmit(
generated, expected,

View File

@ -33,8 +33,8 @@ import {SourceFileLoader} from '../../../src/ngtsc/sourcemaps';
* @returns The content of the expected source file, stripped of the mapping information.
*/
export function checkMappings(
fs: FileSystem, generated: string, generatedPath: AbsoluteFsPath,
expectedSource: string): string {
fs: FileSystem, generated: string, generatedPath: AbsoluteFsPath, expectedSource: string,
expectedPath: AbsoluteFsPath): string {
const actualMappings = getMappedSegments(fs, generatedPath, generated);
const {expected, mappings} = extractMappings(fs, expectedSource);
@ -49,7 +49,7 @@ export function checkMappings(
if (failures.length > 0) {
throw new Error(
`When checking mappings for ${generatedPath}...\n\n` +
`When checking mappings for ${generatedPath} against ${expectedPath} expected...\n\n` +
`${failures.join('\n\n')}\n\n` +
`All the mappings:\n\n${dumpMappings(actualMappings)}`);
}