From 91ce8c17ff53aec2b48a75055400699902c9e5b2 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 (#28550) 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 #28550 --- packages/compiler-cli/test/ngtsc/env.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/compiler-cli/test/ngtsc/env.ts b/packages/compiler-cli/test/ngtsc/env.ts index 7bdef2262b..3e5d3f9feb 100644 --- a/packages/compiler-cli/test/ngtsc/env.ts +++ b/packages/compiler-cli/test/ngtsc/env.ts @@ -12,19 +12,21 @@ import * as path from 'path'; import * as ts from 'typescript'; import {main, mainDiagnosticsForTest} from '../../src/main'; +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'); } /** @@ -59,6 +61,7 @@ export class NgtscTestEnvironment { "baseUrl": ".", "declaration": true, "target": "es5", + "newLine": "lf", "module": "es2015", "moduleResolution": "node", "lib": ["es6", "dom"],