From eeab91af4ecd69490393b84109ae735b19abedfb Mon Sep 17 00:00:00 2001 From: JoostK Date: Thu, 26 Nov 2020 22:09:48 +0100 Subject: [PATCH] test(compiler-cli): log unexpected compilation errors in compliance test runner (#39862) If the testcase has not specified that errors were expected, then any errors that have occurred should be reported. These errors may have prevented an output file from being generated, which resulted in hard to debug test failures due to missing files. PR Close #39862 --- .../test/compliance/test_helpers/check_errors.ts | 8 ++++++++ .../test/compliance/test_helpers/test_runner.ts | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/compiler-cli/test/compliance/test_helpers/check_errors.ts b/packages/compiler-cli/test/compliance/test_helpers/check_errors.ts index 169c038db9..5eccb24c44 100644 --- a/packages/compiler-cli/test/compliance/test_helpers/check_errors.ts +++ b/packages/compiler-cli/test/compliance/test_helpers/check_errors.ts @@ -22,3 +22,11 @@ export function checkErrors( } } } + +export function checkNoUnexpectedErrors(testPath: string, actualErrors: string[]): void { + if (actualErrors.length > 0) { + throw new Error( + `Unexpected errors occurred for test case at "${testPath}"\n` + + `Errors: ${inspect(actualErrors)}.`); + } +} diff --git a/packages/compiler-cli/test/compliance/test_helpers/test_runner.ts b/packages/compiler-cli/test/compliance/test_helpers/test_runner.ts index 59b48d3506..19501f6c7c 100644 --- a/packages/compiler-cli/test/compliance/test_helpers/test_runner.ts +++ b/packages/compiler-cli/test/compliance/test_helpers/test_runner.ts @@ -9,7 +9,7 @@ import {FileSystem} from '../../../src/ngtsc/file_system'; import {checkExpectations} from '../test_helpers/check_expectations'; import {CompileResult, initMockTestFileSystem} from '../test_helpers/compile_test'; import {ComplianceTest, getAllComplianceTests} from '../test_helpers/get_compliance_tests'; -import {checkErrors} from './check_errors'; +import {checkErrors, checkNoUnexpectedErrors} from './check_errors'; /** * Set up jasmine specs for each of the compliance tests. @@ -46,6 +46,7 @@ export function runTests( test.relativePath, expectation.failureMessage, expectation.expectedErrors, errors); } else { + checkNoUnexpectedErrors(test.relativePath, errors); checkExpectations( fs, test.relativePath, expectation.failureMessage, expectation.files, expectation.extraChecks);