From b012ab210b461f244b113b11f57971db274b77be Mon Sep 17 00:00:00 2001 From: Alan Date: Wed, 6 Mar 2019 09:06:34 +0100 Subject: [PATCH] test: add interm fix for test that rely on an index.d.ts file (#28884) At the moment, certain tests relies on resolving the module with an index.d.ts, this root cause might be some implementations are missing from the mocks. Similar to: https://github.com/angular/angular/commit/58b40453597b1d03353b046fe3d1a3cedef08b1d PR Close #28884 --- packages/compiler-cli/test/test_support.ts | 11 +++++++++-- packages/compiler/test/aot/test_util.ts | 5 +++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/compiler-cli/test/test_support.ts b/packages/compiler-cli/test/test_support.ts index b033097299..34ac6e6a92 100644 --- a/packages/compiler-cli/test/test_support.ts +++ b/packages/compiler-cli/test/test_support.ts @@ -122,8 +122,15 @@ export function setupBazelTo(tmpDirPath: string) { fs.mkdirSync(nodeModulesPath); fs.mkdirSync(angularDirectory); - getAngularPackagesFromRunfiles().forEach( - ({pkgPath, name}) => { fs.symlinkSync(pkgPath, path.join(angularDirectory, name), 'dir'); }); + getAngularPackagesFromRunfiles().forEach(({pkgPath, name}) => { + fs.symlinkSync(pkgPath, path.join(angularDirectory, name), 'dir'); + + // todo: check why we always need an index.d.ts + if (!fs.existsSync(path.join(angularDirectory, name, 'index.d.ts'))) { + fs.symlinkSync( + path.join(pkgPath, `${name}.d.ts`), path.join(angularDirectory, name, 'index.d.ts')); + } + }); // Link typescript const typeScriptSource = resolveNpmTreeArtifact('npm/node_modules/typescript'); diff --git a/packages/compiler/test/aot/test_util.ts b/packages/compiler/test/aot/test_util.ts index ce969725ef..bd1b416821 100644 --- a/packages/compiler/test/aot/test_util.ts +++ b/packages/compiler/test/aot/test_util.ts @@ -591,6 +591,11 @@ function readBazelWrittenFilesFrom( } try { processDirectory(bazelPackageRoot, path.join('/node_modules/@angular', packageName)); + // todo: check why we always need an index.d.ts + if (fs.existsSync(path.join(bazelPackageRoot, `${packageName}.d.ts`))) { + const content = fs.readFileSync(path.join(bazelPackageRoot, `${packageName}.d.ts`), 'utf8'); + map.set(path.join('/node_modules/@angular', packageName, 'index.d.ts'), content); + } } catch (e) { console.error( `Consider adding //packages/${packageName} as a data dependency in the BUILD.bazel rule for the failing test`);