test: fix ngcc unit tests in windows (#30297)

```
//packages/compiler-cli/ngcc/test:test
```

Partially addresses #29785

PR Close #30297
This commit is contained in:
Alan 2019-04-30 14:06:02 +02:00 committed by Alex Rickabaugh
parent 3a7bfc721e
commit 1bd4891c9a
5 changed files with 14 additions and 11 deletions

View File

@ -20,7 +20,5 @@ steps:
# Add Bazel CI config
- copy .codefresh\bazel.rc %ProgramData%\bazel.bazelrc
# Run tests
- yarn bazel test //tools/ts-api-guardian:all //packages/language-service/test //packages/compiler/test //packages/compiler-cli/test:ngc //packages/compiler-cli/test/ngtsc:ngtsc
- yarn test-ivy-aot //packages/animations/test //packages/common/test //packages/forms/test //packages/http/test //packages/platform-browser/test //packages/platform-browser-dynamic/test //packages/router/test
- yarn bazel test //tools/public_api_guard/...
- yarn bazel test //packages/compiler-cli/integrationtest:integrationtest //packages/compiler-cli/test/compliance:compliance
- yarn bazel test //tools/ts-api-guardian:all //tools/public_api_guard/... //packages/language-service/test //packages/compiler-cli/ngcc/test:test //packages/compiler-cli/integrationtest:integrationtest //packages/compiler-cli/test/compliance:compliance //packages/compiler/test //packages/compiler-cli/test:ngc //packages/compiler-cli/test/ngtsc:ngtsc

View File

@ -173,7 +173,7 @@ export abstract class Renderer {
renderDtsFile(dtsFile: ts.SourceFile, renderInfo: DtsRenderInfo): FileInfo[] {
const input = this.extractSourceMap(dtsFile);
const outputText = new MagicString(input.source);
const printer = ts.createPrinter();
const printer = createPrinter();
const importManager = new ImportManager(
this.getImportRewriter(this.bundle.dts !.r3SymbolsFile, false), IMPORT_PREFIX);
@ -476,7 +476,7 @@ export function mergeSourceMaps(
*/
export function renderConstantPool(
sourceFile: ts.SourceFile, constantPool: ConstantPool, imports: ImportManager): string {
const printer = ts.createPrinter();
const printer = createPrinter();
return constantPool.statements
.map(stmt => translateStatement(stmt, imports, NOOP_DEFAULT_IMPORT_RECORDER))
.map(stmt => printer.printNode(ts.EmitHint.Unspecified, stmt, sourceFile))
@ -493,7 +493,7 @@ export function renderConstantPool(
*/
export function renderDefinitions(
sourceFile: ts.SourceFile, compiledClass: CompiledClass, imports: ImportManager): string {
const printer = ts.createPrinter();
const printer = createPrinter();
const name = compiledClass.declaration.name;
const translate = (stmt: Statement) =>
translateStatement(stmt, imports, NOOP_DEFAULT_IMPORT_RECORDER);
@ -529,3 +529,7 @@ function getImportString(
const importAs = importPath ? importManager.generateNamedImport(importPath, importName) : null;
return importAs ? `${importAs.moduleImport}.${importAs.symbol}` : `${importName}`;
}
function createPrinter(): ts.Printer {
return ts.createPrinter({newLine: ts.NewLineKind.LineFeed});
}

View File

@ -70,7 +70,7 @@ describe('DependencyHost', () => {
expect(dependencies.size).toBe(0);
expect(missing.size).toBe(0);
expect(deepImports.size).toBe(1);
expect(deepImports.has('/node_modules/lib-1/deep/import')).toBe(true);
expect(deepImports.has(_('/node_modules/lib-1/deep/import'))).toBe(true);
});
it('should recurse into internal dependencies', () => {

View File

@ -12,7 +12,7 @@ import {getEntryPointInfo} from '../../src/packages/entry_point';
import {MockFileSystem} from '../helpers/mock_file_system';
import {MockLogger} from '../helpers/mock_logger';
const _ = AbsoluteFsPath.fromUnchecked;
const _ = AbsoluteFsPath.from;
describe('getEntryPointInfo()', () => {
const SOME_PACKAGE = _('/some_package');

View File

@ -11,7 +11,7 @@ import {EntryPointBundle} from '../../src/packages/entry_point_bundle';
import {InPlaceFileWriter} from '../../src/writing/in_place_file_writer';
import {MockFileSystem} from '../helpers/mock_file_system';
const _ = AbsoluteFsPath.fromUnchecked;
const _ = AbsoluteFsPath.from;
function createMockFileSystem() {
return new MockFileSystem({
@ -71,13 +71,14 @@ describe('InPlaceFileWriter', () => {
it('should error if the backup file already exists', () => {
const fs = createMockFileSystem();
const fileWriter = new InPlaceFileWriter(fs);
const absoluteBackupPath = _('/package/path/already-backed-up.js');
expect(
() => fileWriter.writeBundle(
{} as EntryPoint, {} as EntryPointBundle,
[
{path: _('/package/path/already-backed-up.js'), contents: 'MODIFIED BACKED UP'},
{path: absoluteBackupPath, contents: 'MODIFIED BACKED UP'},
]))
.toThrowError(
'Tried to overwrite /package/path/already-backed-up.js.__ivy_ngcc_bak with an ngcc back up file, which is disallowed.');
`Tried to overwrite ${absoluteBackupPath}.__ivy_ngcc_bak with an ngcc back up file, which is disallowed.`);
});
});