From d4df5d4ed6ffbd55ddd458003ca5cc7318929fd2 Mon Sep 17 00:00:00 2001 From: James Wright Date: Mon, 31 Aug 2020 16:01:07 -0700 Subject: [PATCH] RELNOTES: Fix edge-case in TestCase autodiscovery. PiperOrigin-RevId: 329396478 --- closure/goog/testing/testcase.js | 2 +- closure/goog/testing/testcase_test.js | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/closure/goog/testing/testcase.js b/closure/goog/testing/testcase.js index 4a7976a537..9676d59b7a 100644 --- a/closure/goog/testing/testcase.js +++ b/closure/goog/testing/testcase.js @@ -1435,7 +1435,7 @@ goog.testing.TestCase.prototype.addTestObj_ = function(obj, name, objChain) { var fullTestName = name + (testName && name ? '_' : '') + testName; if (goog.isFunction(testProperty)) { this.addNewTest(fullTestName, testProperty, obj, objChain); - } else if (goog.isObject(testProperty)) { + } else if (goog.isObject(testProperty) && !Array.isArray(testProperty)) { // To prevent infinite loops. if (!goog.array.contains(objChain, testProperty)) { goog.asserts.assertObject(testProperty); diff --git a/closure/goog/testing/testcase_test.js b/closure/goog/testing/testcase_test.js index 741dde0bff..2fbc737968 100644 --- a/closure/goog/testing/testcase_test.js +++ b/closure/goog/testing/testcase_test.js @@ -179,6 +179,20 @@ goog.global.mockTestName = function() { return failGoogPromise(); }; +/** + * A variable with the same autodiscovery prefix, used by + * `testInitializeTestCase`. TestCase does not support auto-discovering tests + * within Arrays, either as functions added to the array object or as a value + * within the array (as it never recurses into the content of the array). + */ +goog.global.mockTestNameValues = ['hello', 'world']; +/** + * @return {!GoogPromise} + */ +goog.global.mockTestNameValues.mockTestNameTestShouldNotBeRun = function() { + return failGoogPromise(); +}; + testSuite({ setUp() { events = [];