Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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