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
This commit is contained in:
JoostK 2020-11-26 22:09:48 +01:00 committed by Misko Hevery
parent 744f46c37d
commit eeab91af4e
2 changed files with 10 additions and 1 deletions

View File

@ -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)}.`);
}
}

View File

@ -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);