Skip to content

Commit

Permalink
build: add npm package manifest to npm_integration_test (#35669)
Browse files Browse the repository at this point in the history
PR Close #35669
  • Loading branch information
gregmagolan authored and mhevery committed Feb 26, 2020
1 parent f9f44bf commit 1f3dd00
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 4 deletions.
41 changes: 37 additions & 4 deletions .bazelignore
@@ -1,18 +1,22 @@
# Bazel does not yet support wildcards or other .gitignore semantics for
# .bazelignore. Two issues for this feature request are outstanding:
# https://github.com/bazelbuild/bazel/issues/7093
# https://github.com/bazelbuild/bazel/issues/8106
.git
node_modules
dist
aio/content
aio/node_modules
aio/tools/examples/shared/node_modules
packages/bazel/node_modules
integration/bazel/bazel-bazel
integration/bazel/bazel-bin
integration/bazel/bazel-out
integration/bazel/bazel-testlogs
integration/bazel-schematics/demo
# All integration test node_modules folders
integration/bazel/node_modules
integration/bazel/.yarn_local_cache
integration/bazel-schematics/node_modules
integration/bazel-schematics/.yarn_local_cache
integration/bazel-schematics/demo
integration/cli-hello-world/node_modules
integration/cli-hello-world-ivy-compat/node_modules
integration/cli-hello-world-ivy-i18n/node_modules
Expand All @@ -37,6 +41,9 @@ integration/side-effects/node_modules
integration/terser/node_modules
integration/typings_test_ts36/node_modules
integration/typings_test_ts37/node_modules
# All integration test .yarn_local_cache folders
integration/bazel/.yarn_local_cache
integration/bazel-schematics/.yarn_local_cache
integration/cli-hello-world/.yarn_local_cache
integration/cli-hello-world-ivy-compat/.yarn_local_cache
integration/cli-hello-world-ivy-i18n/.yarn_local_cache
Expand All @@ -61,4 +68,30 @@ integration/side-effects/.yarn_local_cache
integration/terser/.yarn_local_cache
integration/typings_test_ts36/.yarn_local_cache
integration/typings_test_ts37/.yarn_local_cache
packages/bazel/node_modules
# All integration test NPM_PACKAGE_MANIFEST.json folders
integration/bazel/NPM_PACKAGE_MANIFEST.json
integration/bazel-schematics/NPM_PACKAGE_MANIFEST.json
integration/cli-hello-world/NPM_PACKAGE_MANIFEST.json
integration/cli-hello-world-ivy-compat/NPM_PACKAGE_MANIFEST.json
integration/cli-hello-world-ivy-i18n/NPM_PACKAGE_MANIFEST.json
integration/cli-hello-world-ivy-minimal/NPM_PACKAGE_MANIFEST.json
integration/cli-hello-world-lazy/NPM_PACKAGE_MANIFEST.json
integration/cli-hello-world-lazy-rollup/NPM_PACKAGE_MANIFEST.json
integration/dynamic-compiler/NPM_PACKAGE_MANIFEST.json
integration/hello_world__closure/NPM_PACKAGE_MANIFEST.json
integration/hello_world__systemjs_umd/NPM_PACKAGE_MANIFEST.json
integration/i18n/NPM_PACKAGE_MANIFEST.json
integration/injectable-def/NPM_PACKAGE_MANIFEST.json
integration/ivy-i18n/NPM_PACKAGE_MANIFEST.json
integration/language_service_plugin/NPM_PACKAGE_MANIFEST.json
integration/ng_elements/NPM_PACKAGE_MANIFEST.json
integration/ng_elements_schematics/NPM_PACKAGE_MANIFEST.json
integration/ng_update/NPM_PACKAGE_MANIFEST.json
integration/ng_update_migrations/NPM_PACKAGE_MANIFEST.json
integration/ngcc/NPM_PACKAGE_MANIFEST.json
integration/platform-server/NPM_PACKAGE_MANIFEST.json
integration/service-worker-schema/NPM_PACKAGE_MANIFEST.json
integration/side-effects/NPM_PACKAGE_MANIFEST.json
integration/terser/NPM_PACKAGE_MANIFEST.json
integration/typings_test_ts36/NPM_PACKAGE_MANIFEST.json
integration/typings_test_ts37/NPM_PACKAGE_MANIFEST.json
1 change: 1 addition & 0 deletions integration/.gitignore
Expand Up @@ -9,3 +9,4 @@ tmp/
**/*.ngsummary.json
**/*.ngsummary.ts
**/.yarn_local_cache*
**/NPM_PACKAGE_MANIFEST.json
22 changes: 22 additions & 0 deletions tools/npm_integration_test/test_runner.js
Expand Up @@ -140,6 +140,7 @@ class TestRunner {
this.config = config;
this.successful = 0;
this._setupTestFiles();
this._writeNpmPackageManifest();
}

/**
Expand Down Expand Up @@ -297,6 +298,27 @@ class TestRunner {
log(`test files from '${rootDirectory(this.config.testFiles)}' copied to tmp folder ${this.testRoot}`);
}
}

/**
* @internal
*
* Write an NPM_PACKAGE_MANIFEST.json file to the test root with a mapping of
* the npm package mappings for this this test. Integration tests can opt
* to use this mappings file instead of the built-in `patch-package-json`
* command.
*/
_writeNpmPackageManifest() {
if (!this.testRoot) {
fail(`test files not yet setup`);
}
const manifest = {};
for (const key of Object.keys(this.config.npmPackages)) {
manifest[key] = runfiles.resolveWorkspaceRelative(this.config.npmPackages[key]);
}
const manifestPath = `${this.testRoot}/NPM_PACKAGE_MANIFEST.json`;
fs.writeFileSync(manifestPath, JSON.stringify(manifest, null, 2));
log(`npm package manifest written to ${manifestPath}`);
}
}

const config = require(process.argv[2]);
Expand Down

0 comments on commit 1f3dd00

Please sign in to comment.