From dfe64a0060795e7e59f7562436436306ccd829ef Mon Sep 17 00:00:00 2001 From: Pete Bacon Darwin Date: Tue, 29 Dec 2020 15:17:10 +0000 Subject: [PATCH] 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 --- .../test/compliance/test_helpers/check_expectations.ts | 2 +- .../test/compliance/test_helpers/sourcemap_helpers.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/compiler-cli/test/compliance/test_helpers/check_expectations.ts b/packages/compiler-cli/test/compliance/test_helpers/check_expectations.ts index a89930b70d..74c74aef11 100644 --- a/packages/compiler-cli/test/compliance/test_helpers/check_expectations.ts +++ b/packages/compiler-cli/test/compliance/test_helpers/check_expectations.ts @@ -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, diff --git a/packages/compiler-cli/test/compliance/test_helpers/sourcemap_helpers.ts b/packages/compiler-cli/test/compliance/test_helpers/sourcemap_helpers.ts index 19ef8f16e9..75c43fff1e 100644 --- a/packages/compiler-cli/test/compliance/test_helpers/sourcemap_helpers.ts +++ b/packages/compiler-cli/test/compliance/test_helpers/sourcemap_helpers.ts @@ -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)}`); }