Skip to content

Commit

Permalink
test: fix ngc-wrapped bazel tests in windows (angular#30111)
Browse files Browse the repository at this point in the history
Partially addresses angular#29785

PR Close angular#30111
  • Loading branch information
alan-agius4 authored and BioPhoton committed May 21, 2019
1 parent 570a1da commit 9cbce90
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
2 changes: 1 addition & 1 deletion packages/bazel/src/ngc-wrapped/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ export function compile({allDepsCompiledWithBazel = true, compilerOpts, tsHost,
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);
tsHost.writeFile =
Expand Down
18 changes: 8 additions & 10 deletions packages/bazel/test/ngc-wrapped/test_support.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import {runOneBuild} from '@angular/bazel';
import * as fs from 'fs';
import * as os from 'os';
import * as path from 'path';
import * as ts from 'typescript';

Expand Down Expand Up @@ -47,9 +46,7 @@ export function setup(
const bazelBinPath = path.resolve(basePath, bazelBin);
fs.mkdirSync(bazelBinPath);

const angularCorePath = path.resolve(runfilesPath, 'angular', 'packages', 'core');
const ngFiles = listFilesRecursive(angularCorePath);

const angularCorePath = path.dirname(require.resolve('angular/packages/core'));
const tsConfigJsonPath = path.resolve(basePath, tsconfig);

return {
Expand Down Expand Up @@ -107,7 +104,10 @@ export function setup(
const files = [...compilationTargetSrc];

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) {
files.push(...listFilesRecursive(depPath).filter(f => f.endsWith('.d.ts')));
Expand All @@ -116,14 +116,12 @@ export function setup(
const pathMappingObj = {};
for (const mapping of pathMapping) {
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(
path.resolve(
runfilesPath, 'angular', 'packages', 'bazel', 'test', 'ngc-wrapped', 'empty',
'empty_tsconfig.json'),
read);
require.resolve('angular/packages/bazel/test/ngc-wrapped/empty/empty_tsconfig.json'), read);

const tsconfig = createTsConfig({
defaultTsConfig: emptyTsConfig.config,
Expand Down
5 changes: 2 additions & 3 deletions packages/bazel/test/ngc-wrapped/tsconfig_template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
*/

import * as path from 'path';
import * as ts from 'typescript';

const EXT = /(\.ts|\.d\.ts|\.js|\.jsx|\.tsx)$/;

Expand All @@ -32,7 +31,6 @@ export function createTsConfig(options: TsConfigOptions) {
const result = options.defaultTsConfig;

return {
'extends': '../angular/packages/bazel/test/ngc-wrapped/empty/tsconfig',
'compilerOptions': {
...result.compilerOptions,
'outDir': options.outDir,
Expand Down Expand Up @@ -71,7 +69,8 @@ export function createTsConfig(options: TsConfigOptions) {
'tsickleExternsPath': '',
// we don't copy the node_modules into our tmp dir, so we should look in
// the original workspace directory for it
'nodeModulesPrefix': '../npm/node_modules',
'nodeModulesPrefix':
path.join(require.resolve('npm/node_modules/typescript/package.json'), '../../'),
},
'files': options.files,
'angularCompilerOptions': {
Expand Down

0 comments on commit 9cbce90

Please sign in to comment.