mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
test(compiler-cli): improve compliance test performance (#39956)
The newly built compliance test runner was not using the shared source
file cache that was added in b627f7f02e,
which offers a significant performance boost to the compliance test
targets.
PR Close #39956
This commit is contained in:
@@ -7,5 +7,6 @@
|
||||
*/
|
||||
export * from './src/utils';
|
||||
export * from './src/cached_source_files';
|
||||
export * from './src/compiler_host';
|
||||
export * from './src/mock_file_loading';
|
||||
export * from './src/runfile_helpers';
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright Google LLC All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import * as ts from 'typescript';
|
||||
import {NgtscCompilerHost} from '../../file_system';
|
||||
import {getCachedSourceFile} from './cached_source_files';
|
||||
|
||||
/**
|
||||
* A compiler host intended to improve test performance by caching default library source files for
|
||||
* reuse across tests.
|
||||
*/
|
||||
export class NgtscTestCompilerHost extends NgtscCompilerHost {
|
||||
getSourceFile(fileName: string, languageVersion: ts.ScriptTarget): ts.SourceFile|undefined {
|
||||
const cachedSf = getCachedSourceFile(fileName, () => this.readFile(fileName));
|
||||
if (cachedSf !== null) {
|
||||
return cachedSf;
|
||||
}
|
||||
return super.getSourceFile(fileName, languageVersion);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user