test: fix ngc-wrapped bazel tests in windows (#30111)

Partially addresses #29785

PR Close #30111
This commit is contained in:
Alan Agius 2019-04-26 10:15:17 +02:00 committed by Andrew Kushnir
parent 28a1caa0ed
commit 67012509a8
3 changed files with 11 additions and 14 deletions

View File

@ -202,7 +202,7 @@ export function compile({allDepsCompiledWithBazel = true, compilerOpts, tsHost,
throw new Error(`Couldn't find bazel bin in the rootDirs: ${compilerOpts.rootDirs}`); throw new Error(`Couldn't find bazel bin in the rootDirs: ${compilerOpts.rootDirs}`);
} }
const writtenExpectedOuts = [...expectedOuts]; const writtenExpectedOuts = expectedOuts.map(p => p.replace(/\\/g, '/'));
const originalWriteFile = tsHost.writeFile.bind(tsHost); const originalWriteFile = tsHost.writeFile.bind(tsHost);
tsHost.writeFile = tsHost.writeFile =

View File

@ -8,7 +8,6 @@
import {runOneBuild} from '@angular/bazel'; import {runOneBuild} from '@angular/bazel';
import * as fs from 'fs'; import * as fs from 'fs';
import * as os from 'os';
import * as path from 'path'; import * as path from 'path';
import * as ts from 'typescript'; import * as ts from 'typescript';
@ -47,9 +46,7 @@ export function setup(
const bazelBinPath = path.resolve(basePath, bazelBin); const bazelBinPath = path.resolve(basePath, bazelBin);
fs.mkdirSync(bazelBinPath); fs.mkdirSync(bazelBinPath);
const angularCorePath = path.resolve(runfilesPath, 'angular', 'packages', 'core'); const angularCorePath = path.dirname(require.resolve('angular/packages/core'));
const ngFiles = listFilesRecursive(angularCorePath);
const tsConfigJsonPath = path.resolve(basePath, tsconfig); const tsConfigJsonPath = path.resolve(basePath, tsconfig);
return { return {
@ -107,7 +104,10 @@ export function setup(
const files = [...compilationTargetSrc]; const files = [...compilationTargetSrc];
depPaths = depPaths.concat([angularCorePath]); depPaths = depPaths.concat([angularCorePath]);
pathMapping = pathMapping.concat([{moduleName: '@angular/core', path: angularCorePath}]); pathMapping = pathMapping.concat([
{moduleName: '@angular/core', path: angularCorePath},
{moduleName: 'angular/packages/core', path: angularCorePath}
]);
for (const depPath of depPaths) { for (const depPath of depPaths) {
files.push(...listFilesRecursive(depPath).filter(f => f.endsWith('.d.ts'))); files.push(...listFilesRecursive(depPath).filter(f => f.endsWith('.d.ts')));
@ -116,14 +116,12 @@ export function setup(
const pathMappingObj = {}; const pathMappingObj = {};
for (const mapping of pathMapping) { for (const mapping of pathMapping) {
pathMappingObj[mapping.moduleName] = [mapping.path]; pathMappingObj[mapping.moduleName] = [mapping.path];
pathMappingObj[path.join(mapping.moduleName, '*')] = [path.join(mapping.path, '*')]; pathMappingObj[path.posix.join(mapping.moduleName, '*')] =
[path.posix.join(mapping.path, '*')];
} }
const emptyTsConfig = ts.readConfigFile( const emptyTsConfig = ts.readConfigFile(
path.resolve( require.resolve('angular/packages/bazel/test/ngc-wrapped/empty/empty_tsconfig.json'), read);
runfilesPath, 'angular', 'packages', 'bazel', 'test', 'ngc-wrapped', 'empty',
'empty_tsconfig.json'),
read);
const tsconfig = createTsConfig({ const tsconfig = createTsConfig({
defaultTsConfig: emptyTsConfig.config, defaultTsConfig: emptyTsConfig.config,

View File

@ -7,7 +7,6 @@
*/ */
import * as path from 'path'; import * as path from 'path';
import * as ts from 'typescript';
const EXT = /(\.ts|\.d\.ts|\.js|\.jsx|\.tsx)$/; const EXT = /(\.ts|\.d\.ts|\.js|\.jsx|\.tsx)$/;
@ -32,7 +31,6 @@ export function createTsConfig(options: TsConfigOptions) {
const result = options.defaultTsConfig; const result = options.defaultTsConfig;
return { return {
'extends': '../angular/packages/bazel/test/ngc-wrapped/empty/tsconfig',
'compilerOptions': { 'compilerOptions': {
...result.compilerOptions, ...result.compilerOptions,
'outDir': options.outDir, 'outDir': options.outDir,
@ -71,7 +69,8 @@ export function createTsConfig(options: TsConfigOptions) {
'tsickleExternsPath': '', 'tsickleExternsPath': '',
// we don't copy the node_modules into our tmp dir, so we should look in // we don't copy the node_modules into our tmp dir, so we should look in
// the original workspace directory for it // the original workspace directory for it
'nodeModulesPrefix': '../npm/node_modules', 'nodeModulesPrefix':
path.join(require.resolve('npm/node_modules/typescript/package.json'), '../../'),
}, },
'files': options.files, 'files': options.files,
'angularCompilerOptions': { 'angularCompilerOptions': {