From 96941c7300edb51a09b2df46bfdca2fafaca2a9a Mon Sep 17 00:00:00 2001 From: atscott Date: Fri, 10 Jan 2020 13:39:34 -0800 Subject: [PATCH] Revert "build: cleanup //tools/ts-api-guardian:tests target (#34589)" (#34730) This reverts commit 7a63e4f7d5b3a59a1ae45340cdd72ffb8b22730c. PR Close #34730 --- tools/ts-api-guardian/BUILD.bazel | 7 +++++-- tools/ts-api-guardian/test/bootstrap.ts | 10 ++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/tools/ts-api-guardian/BUILD.bazel b/tools/ts-api-guardian/BUILD.bazel index e27f2a55cf..7841891db7 100644 --- a/tools/ts-api-guardian/BUILD.bazel +++ b/tools/ts-api-guardian/BUILD.bazel @@ -1,7 +1,7 @@ # BEGIN-INTERNAL load("@build_bazel_rules_nodejs//:index.bzl", "pkg_npm") +load("@npm_bazel_jasmine//:index.bzl", "jasmine_node_test") load("@npm_bazel_typescript//:index.bzl", "ts_library") -load("//tools:defaults.bzl", "jasmine_node_test") ts_library( name = "lib", @@ -95,13 +95,16 @@ jasmine_node_test( srcs = [ ":test_lib", ], - bootstrap = [":bootstrap_es5"], data = glob([ "test/fixtures/*.ts", "test/fixtures/*.patch", ]) + [ + ":bootstrap_es5", ":ts-api-guardian", + # TODO: remove this once the boostrap.js workaround has been removed. + ":package.json", ], + templated_args = ["--node_options=--require=$(rlocation $(location :bootstrap_es5))"], ) # END-INTERNAL diff --git a/tools/ts-api-guardian/test/bootstrap.ts b/tools/ts-api-guardian/test/bootstrap.ts index de7be2c2d2..6b57f8f54c 100644 --- a/tools/ts-api-guardian/test/bootstrap.ts +++ b/tools/ts-api-guardian/test/bootstrap.ts @@ -6,11 +6,13 @@ * found in the LICENSE file at https://angular.io/license */ -const runfiles = require(process.env['BAZEL_NODE_RUNFILES_HELPER']); +import * as path from 'path'; -// Change directories to the path of the ts-api-guardian source tree. We need to resolve an actual -// path of a tree because we want to determine the path to the directory that includes all +// Resolve the path to the package.json of the ts-api-guardian. We need to resolve an actual +// path of a runfile because we want to determine the path to the directory that includes all // test fixture runfiles. On Windows this is usually the original non-sandboxed disk location, // otherwise this just refers to the runfile directory with all the proper symlinked files. // TODO: remove the whole bootstrap file once the tests are Bazel and Windows compatible. -process.chdir(runfiles.resolve('angular/tools/ts-api-guardian')); +const runfilesDirectory = path.dirname(require.resolve('../package.json')); + +process.chdir(runfilesDirectory);