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:
parent
9f662e1313
commit
dfe64a0060
|
@ -58,7 +58,7 @@ export function checkExpectations(
|
||||||
const generated = fs.readFile(generatedPath);
|
const generated = fs.readFile(generatedPath);
|
||||||
let expected = fs.readFile(expectedPath);
|
let expected = fs.readFile(expectedPath);
|
||||||
expected = replaceMacros(expected);
|
expected = replaceMacros(expected);
|
||||||
expected = checkMappings(fs, generated, generatedPath, expected);
|
expected = checkMappings(fs, generated, generatedPath, expected, expectedPath);
|
||||||
|
|
||||||
expectEmit(
|
expectEmit(
|
||||||
generated, expected,
|
generated, expected,
|
||||||
|
|
|
@ -33,8 +33,8 @@ import {SourceFileLoader} from '../../../src/ngtsc/sourcemaps';
|
||||||
* @returns The content of the expected source file, stripped of the mapping information.
|
* @returns The content of the expected source file, stripped of the mapping information.
|
||||||
*/
|
*/
|
||||||
export function checkMappings(
|
export function checkMappings(
|
||||||
fs: FileSystem, generated: string, generatedPath: AbsoluteFsPath,
|
fs: FileSystem, generated: string, generatedPath: AbsoluteFsPath, expectedSource: string,
|
||||||
expectedSource: string): string {
|
expectedPath: AbsoluteFsPath): string {
|
||||||
const actualMappings = getMappedSegments(fs, generatedPath, generated);
|
const actualMappings = getMappedSegments(fs, generatedPath, generated);
|
||||||
|
|
||||||
const {expected, mappings} = extractMappings(fs, expectedSource);
|
const {expected, mappings} = extractMappings(fs, expectedSource);
|
||||||
|
@ -49,7 +49,7 @@ export function checkMappings(
|
||||||
|
|
||||||
if (failures.length > 0) {
|
if (failures.length > 0) {
|
||||||
throw new Error(
|
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` +
|
`${failures.join('\n\n')}\n\n` +
|
||||||
`All the mappings:\n\n${dumpMappings(actualMappings)}`);
|
`All the mappings:\n\n${dumpMappings(actualMappings)}`);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue