From c5ea3d5b0ed23e56f34e8cf3f4a375fb398ab981 Mon Sep 17 00:00:00 2001 From: Pete Bacon Darwin Date: Mon, 30 Nov 2020 14:25:21 +0000 Subject: [PATCH] test(compiler-cli): ensure that golden partial files are parsed accurately (#39939) Previously files were serialized with an extra newline seperator that was not removed when parsing. This caused the parsed file to start with an extra newline that invalidated its source-map. Also, the splitting was producing an empty entry at the start of the extracted golden files which is now ignored. PR Close #39939 --- .../test/compliance/test_helpers/golden_partials.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/compiler-cli/test/compliance/test_helpers/golden_partials.ts b/packages/compiler-cli/test/compliance/test_helpers/golden_partials.ts index 579d9cdb06..680d7cdf77 100644 --- a/packages/compiler-cli/test/compliance/test_helpers/golden_partials.ts +++ b/packages/compiler-cli/test/compliance/test_helpers/golden_partials.ts @@ -11,7 +11,7 @@ const headerStart = ' * PARTIAL FILE: '; const headerEnd = - '\n ****************************************************************************************************/'; + '\n ****************************************************************************************************/\n'; /** * Render the partially compiled files into a single golden partial output string. @@ -19,7 +19,7 @@ const headerEnd = * @param files The partially compiled files to be rendered. */ export function renderGoldenPartial(files: PartiallyCompiledFile[]): string { - return files.map(file => `${headerStart + file.path + headerEnd}\n${file.content}`).join('\n'); + return files.map(file => `${headerStart + file.path + headerEnd}${file.content}`).join('\n'); } /** @@ -35,7 +35,9 @@ export function parseGoldenPartial(partialContent: string): PartiallyCompiledFil const partials = partialContent.split(headerStart); for (const partial of partials) { const [path, content] = partial.split(headerEnd); - files.push({path, content}); + if (path) { + files.push({path, content}); + } } return files; }