From 6174dffc2ac266b1c9d11f05999d0f76842e790e Mon Sep 17 00:00:00 2001 From: Greg Magolan Date: Fri, 10 Jan 2020 16:00:49 -0800 Subject: [PATCH] test: test for regression where jasmine_node_test passes silently (#34736) Adds tests to verify that jasmine_node_test targets fail as expected. This is to catch any future regressions to jasmine_node_test where tests pass silently without executing. See https://github.com/bazelbuild/rules_nodejs/pull/1540 for an example of a potential regression. PR Close #34736 --- tools/testing/BUILD.bazel | 26 +++++++++++++++++++++++++- tools/testing/fail.spec.js | 8 ++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 tools/testing/fail.spec.js diff --git a/tools/testing/BUILD.bazel b/tools/testing/BUILD.bazel index e29e450f40..8d00f94bd3 100644 --- a/tools/testing/BUILD.bazel +++ b/tools/testing/BUILD.bazel @@ -1,4 +1,4 @@ -load("//tools:defaults.bzl", "ts_library") +load("//tools:defaults.bzl", "jasmine_node_test", "ts_library") package(default_visibility = ["//visibility:public"]) @@ -38,3 +38,27 @@ ts_library( "//packages:types", ], ) + +# A test to verify that jasmine_node_test targets fail as expected. +# This is to catch any future regressions to jasmine_node_test where +# tests pass silently without executing. +# See https://github.com/bazelbuild/rules_nodejs/pull/1540 for an example +# of a potential regression. +jasmine_node_test( + name = "fail_test", + srcs = ["fail.spec.js"], + expected_exit_code = 55, +) + +# A test to verify that jasmine_node_test targets fail as expected +# when there is a bootstrap script set. +# This is to catch any future regressions to jasmine_node_test where +# tests pass silently without executing. +# See https://github.com/bazelbuild/rules_nodejs/pull/1540 for an example +# of a potential regression. +jasmine_node_test( + name = "fail_bootstrap_test", + srcs = ["fail.spec.js"], + bootstrap = ["//tools/testing:node_es5"], + expected_exit_code = 55, +) diff --git a/tools/testing/fail.spec.js b/tools/testing/fail.spec.js new file mode 100644 index 0000000000..051229b33e --- /dev/null +++ b/tools/testing/fail.spec.js @@ -0,0 +1,8 @@ +/** + * @license + * Copyright Google Inc. All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ +process.exit(55); \ No newline at end of file