build: support running ngtsc tests on windows (#28352)
Currently the "ngtsc` testing helpers resolve the `fake_core` NPM package using the `TEST_SRCDIR` variable. This is problematic on Windows where Bazel runfiles are not symlinked into the runfiles directory. In order to properly resolve the NPM Bazel tree artifact, we use the `resolveTreeNpmArtifact` runfile helper that properly resolves the artifact properly on all platforms. PR Close #28352
This commit is contained in:
parent
c10d86cbc0
commit
40da1be1e1
@ -14,19 +14,21 @@ import * as ts from 'typescript';
|
|||||||
import {createCompilerHost, createProgram} from '../../ngtools2';
|
import {createCompilerHost, createProgram} from '../../ngtools2';
|
||||||
import {main, mainDiagnosticsForTest, readNgcCommandLineAndConfiguration} from '../../src/main';
|
import {main, mainDiagnosticsForTest, readNgcCommandLineAndConfiguration} from '../../src/main';
|
||||||
import {LazyRoute} from '../../src/ngtsc/routing';
|
import {LazyRoute} from '../../src/ngtsc/routing';
|
||||||
import {setup, TestSupport} from '../test_support';
|
import {resolveNpmTreeArtifact} from '../runfile_helpers';
|
||||||
|
import {TestSupport, setup} from '../test_support';
|
||||||
|
|
||||||
function setupFakeCore(support: TestSupport): void {
|
function setupFakeCore(support: TestSupport): void {
|
||||||
if (!process.env.TEST_SRCDIR) {
|
if (!process.env.TEST_SRCDIR) {
|
||||||
throw new Error('`setupFakeCore` must be run within a Bazel test');
|
throw new Error('`setupFakeCore` must be run within a Bazel test');
|
||||||
}
|
}
|
||||||
const fakeCore = path.join(
|
|
||||||
process.env.TEST_SRCDIR, 'angular/packages/compiler-cli/test/ngtsc/fake_core/npm_package');
|
const fakeNpmPackageDir =
|
||||||
|
resolveNpmTreeArtifact('angular/packages/compiler-cli/test/ngtsc/fake_core/npm_package');
|
||||||
|
|
||||||
const nodeModulesPath = path.join(support.basePath, 'node_modules');
|
const nodeModulesPath = path.join(support.basePath, 'node_modules');
|
||||||
const angularCoreDirectory = path.join(nodeModulesPath, '@angular/core');
|
const angularCoreDirectory = path.join(nodeModulesPath, '@angular/core');
|
||||||
|
|
||||||
fs.symlinkSync(fakeCore, angularCoreDirectory);
|
fs.symlinkSync(fakeNpmPackageDir, angularCoreDirectory, 'dir');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -61,6 +63,7 @@ export class NgtscTestEnvironment {
|
|||||||
"baseUrl": ".",
|
"baseUrl": ".",
|
||||||
"declaration": true,
|
"declaration": true,
|
||||||
"target": "es5",
|
"target": "es5",
|
||||||
|
"newLine": "lf",
|
||||||
"module": "es2015",
|
"module": "es2015",
|
||||||
"moduleResolution": "node",
|
"moduleResolution": "node",
|
||||||
"lib": ["es6", "dom"],
|
"lib": ["es6", "dom"],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user