test(ivy): introduce route testing mode for ngtsc tests (#27697)

This commit introduces a new mode for the NgtscTestEnvironment which
builds the NgtscProgram and then asks for the list of lazy routes,
instead of running the TS emit phase.

PR Close #27697
This commit is contained in:
Alex Rickabaugh 2018-11-16 17:54:43 +01:00
parent da85cee07c
commit 41b2499f17
3 changed files with 12 additions and 2 deletions

View File

@ -115,7 +115,7 @@ function createEmitCallback(options: api.CompilerOptions): api.TsEmitCallback|un
export interface NgcParsedConfiguration extends ParsedConfiguration { watch?: boolean; }
function readNgcCommandLineAndConfiguration(args: string[]): NgcParsedConfiguration {
export function readNgcCommandLineAndConfiguration(args: string[]): NgcParsedConfiguration {
const options: api.CompilerOptions = {};
const parsedArgs = require('minimist')(args);
if (parsedArgs.i18nFile) options.i18nInFile = parsedArgs.i18nFile;

View File

@ -7,6 +7,7 @@ ts_library(
deps = [
"//packages/compiler",
"//packages/compiler-cli",
"//packages/compiler-cli/src/ngtsc/routing",
"//packages/compiler-cli/test:test_utils",
"@ngdeps//typescript",
],

View File

@ -11,7 +11,9 @@ import * as fs from 'fs';
import * as path from 'path';
import * as ts from 'typescript';
import {main, mainDiagnosticsForTest} from '../../src/main';
import {createCompilerHost, createProgram} from '../../ngtools2';
import {main, mainDiagnosticsForTest, readNgcCommandLineAndConfiguration} from '../../src/main';
import {LazyRoute} from '../../src/ngtsc/routing';
import {TestSupport, isInBazel, setup} from '../test_support';
function setupFakeCore(support: TestSupport): void {
@ -127,5 +129,12 @@ export class NgtscTestEnvironment {
return mainDiagnosticsForTest(['-p', this.basePath]) as ReadonlyArray<ts.Diagnostic>;
}
driveRoutes(entryPoint?: string): LazyRoute[] {
const {rootNames, options} = readNgcCommandLineAndConfiguration(['-p', this.basePath]);
const host = createCompilerHost({options});
const program = createProgram({rootNames, host, options});
return program.listLazyRoutes(entryPoint);
}
static get supported(): boolean { return isInBazel(); }
}