test: fix several bazel compiler-cli tests in windows (#30189)

```
//packages/compiler-cli/integrationtest:integrationtest
//packages/compiler-cli/test/compliance:compliance
```

Partially addresses #29785

PR Close #30189
This commit is contained in:
Alan 2019-04-30 10:18:20 +02:00 committed by Kara Erickson
parent b40f6f3eae
commit 1660b34e2d
3 changed files with 17 additions and 16 deletions

View File

@ -23,3 +23,4 @@ steps:
- yarn bazel test //tools/ts-api-guardian:all //packages/language-service/test
- yarn test-ivy-aot //packages/animations/test //packages/common/test //packages/forms/test //packages/http/test //packages/platform-browser/test //packages/platform-browser-dynamic/test //packages/router/test
- yarn bazel test //tools/public_api_guard/...
- yarn bazel test //packages/compiler-cli/integrationtest:integrationtest //packages/compiler-cli/test/compliance:compliance

View File

@ -98,13 +98,8 @@ function symlinkNodeModules() {
Object.keys(requiredNodeModules).forEach(importName => {
const outputPath = path.join(tmpDir, 'node_modules', importName);
const moduleDir = requiredNodeModules[importName];
findFilesWithinDirectory(moduleDir).forEach(filePath => {
const outputFilePath = path.join(outputPath, path.relative(moduleDir, filePath));
shx.mkdir('-p', path.dirname(outputFilePath));
fs.symlinkSync(filePath, outputFilePath);
});
shx.mkdir('-p', path.dirname(outputPath));
fs.symlinkSync(moduleDir, outputPath, 'junction');
});
}
@ -162,5 +157,5 @@ function resolveNpmTreeArtifact(manifestPath, resolveFile = 'package.json') {
/** Finds all files within a specified directory. */
function findFilesWithinDirectory(directoryPath) {
return shx.find(directoryPath).filter(filePath => !fs.statSync(filePath).isDirectory());
return shx.find(directoryPath).filter(filePath => !fs.lstatSync(filePath).isDirectory());
}

View File

@ -576,8 +576,8 @@ function readBazelWrittenFilesFrom(
function processDirectory(dir: string, dest: string) {
const entries = fs.readdirSync(dir);
for (const name of entries) {
const fullName = path.join(dir, name);
const destName = path.join(dest, name);
const fullName = path.posix.join(dir, name);
const destName = path.posix.join(dest, name);
const stat = fs.statSync(fullName);
if (!skip(name, fullName)) {
if (stat.isDirectory()) {
@ -590,11 +590,11 @@ function readBazelWrittenFilesFrom(
}
}
try {
processDirectory(bazelPackageRoot, path.join('/node_modules/@angular', packageName));
processDirectory(bazelPackageRoot, path.posix.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);
map.set(path.posix.join('/node_modules/@angular', packageName, 'index.d.ts'), content);
}
} catch (e) {
console.error(
@ -632,24 +632,25 @@ export function setup(options: {
if (options.compileAngular) {
// If this fails please add //packages/core:npm_package as a test data dependency.
readBazelWrittenFilesFrom(
path.join(sources, 'angular/packages/core/npm_package'), 'core', angularFiles,
resolveNpmTreeArtifact('angular/packages/core/npm_package'), 'core', angularFiles,
skipDirs);
}
if (options.compileFakeCore) {
readBazelWrittenFilesFrom(
path.join(sources, 'angular/packages/compiler-cli/test/ngtsc/fake_core/npm_package'),
resolveNpmTreeArtifact(
'angular/packages/compiler-cli/test/ngtsc/fake_core/npm_package'),
'core', angularFiles, skipDirs);
}
if (options.compileAnimations) {
// If this fails please add //packages/animations:npm_package as a test data dependency.
readBazelWrittenFilesFrom(
path.join(sources, 'angular/packages/animations/npm_package'), 'animations',
resolveNpmTreeArtifact('angular/packages/animations/npm_package'), 'animations',
angularFiles, skipDirs);
}
if (options.compileCommon) {
// If this fails please add //packages/common:npm_package as a test data dependency.
readBazelWrittenFilesFrom(
path.join(sources, 'angular/packages/common/npm_package'), 'common', angularFiles,
resolveNpmTreeArtifact('angular/packages/common/npm_package'), 'common', angularFiles,
skipDirs);
}
return;
@ -750,6 +751,10 @@ function isSourceOrDts(fileName: string): boolean {
return /\.ts$/.test(fileName);
}
function resolveNpmTreeArtifact(manifestPath: string, resolveFile = 'package.json') {
return path.dirname(require.resolve(path.posix.join(manifestPath, resolveFile)));
}
export function compile(
rootDirs: MockData, options: {
emit?: boolean,