From 40da1be1e13b0ad7b92dc424aa9dd1cf934bf49d Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Fri, 25 Jan 2019 19:49:08 +0100 Subject: [PATCH] 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 --- packages/compiler-cli/test/ngtsc/env.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/compiler-cli/test/ngtsc/env.ts b/packages/compiler-cli/test/ngtsc/env.ts index 91fc8a6331..ae4bdbcf60 100644 --- a/packages/compiler-cli/test/ngtsc/env.ts +++ b/packages/compiler-cli/test/ngtsc/env.ts @@ -14,19 +14,21 @@ import * as ts from 'typescript'; import {createCompilerHost, createProgram} from '../../ngtools2'; import {main, mainDiagnosticsForTest, readNgcCommandLineAndConfiguration} from '../../src/main'; 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 { if (!process.env.TEST_SRCDIR) { 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 angularCoreDirectory = path.join(nodeModulesPath, '@angular/core'); - fs.symlinkSync(fakeCore, angularCoreDirectory); + fs.symlinkSync(fakeNpmPackageDir, angularCoreDirectory, 'dir'); } /** @@ -61,6 +63,7 @@ export class NgtscTestEnvironment { "baseUrl": ".", "declaration": true, "target": "es5", + "newLine": "lf", "module": "es2015", "moduleResolution": "node", "lib": ["es6", "dom"],