From 67012509a8ce7f701fde50fa903c6b2785182db6 Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Fri, 26 Apr 2019 10:15:17 +0200 Subject: [PATCH] test: fix ngc-wrapped bazel tests in windows (#30111) Partially addresses #29785 PR Close #30111 --- packages/bazel/src/ngc-wrapped/index.ts | 2 +- .../bazel/test/ngc-wrapped/test_support.ts | 18 ++++++++---------- .../test/ngc-wrapped/tsconfig_template.ts | 5 ++--- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/packages/bazel/src/ngc-wrapped/index.ts b/packages/bazel/src/ngc-wrapped/index.ts index 89c05b7541..f93c908f68 100644 --- a/packages/bazel/src/ngc-wrapped/index.ts +++ b/packages/bazel/src/ngc-wrapped/index.ts @@ -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 = diff --git a/packages/bazel/test/ngc-wrapped/test_support.ts b/packages/bazel/test/ngc-wrapped/test_support.ts index a9a674ee40..2b532f594d 100644 --- a/packages/bazel/test/ngc-wrapped/test_support.ts +++ b/packages/bazel/test/ngc-wrapped/test_support.ts @@ -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'; @@ -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 { @@ -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'))); @@ -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, diff --git a/packages/bazel/test/ngc-wrapped/tsconfig_template.ts b/packages/bazel/test/ngc-wrapped/tsconfig_template.ts index 7f52d2b503..792f9e4b73 100644 --- a/packages/bazel/test/ngc-wrapped/tsconfig_template.ts +++ b/packages/bazel/test/ngc-wrapped/tsconfig_template.ts @@ -7,7 +7,6 @@ */ import * as path from 'path'; -import * as ts from 'typescript'; const EXT = /(\.ts|\.d\.ts|\.js|\.jsx|\.tsx)$/; @@ -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, @@ -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': {