From 7da424d53fa0b9c67c8394bc4444ded4b6e2927d Mon Sep 17 00:00:00 2001 From: Nikolay Krasko Date: Tue, 31 Jan 2017 16:56:22 +0300 Subject: [PATCH] Port setInPerformanceTest -> setInStressTest --- .../test/testFramework/KtUsefulTestCase.java | 34 +++++++++++++++---- 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/compiler/tests-common/org/jetbrains/kotlin/test/testFramework/KtUsefulTestCase.java b/compiler/tests-common/org/jetbrains/kotlin/test/testFramework/KtUsefulTestCase.java index 2d05cee565b..c3535375e3a 100644 --- a/compiler/tests-common/org/jetbrains/kotlin/test/testFramework/KtUsefulTestCase.java +++ b/compiler/tests-common/org/jetbrains/kotlin/test/testFramework/KtUsefulTestCase.java @@ -38,6 +38,7 @@ import junit.framework.TestCase; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.utils.ExceptionUtilsKt; import org.junit.Assert; @@ -95,10 +96,10 @@ public abstract class KtUsefulTestCase extends TestCase { testName = new File(testName).getName(); // in case the test name contains file separators myTempDir = new File(ORIGINAL_TEMP_DIR, TEMP_DIR_MARKER + testName).getPath(); FileUtil.resetCanonicalTempPathCache(myTempDir); - boolean isPerformanceTest = isPerformanceTest(); - ApplicationInfoImpl.setInPerformanceTest(isPerformanceTest); + boolean isStressTest = isStressTest(); + ApplicationInfoImpl.setInStressTest(isStressTest); // turn off Disposer debugging for performance tests - oldDisposerDebug = Disposer.setDebugMode(Disposer.isDebugMode() && !isPerformanceTest); + oldDisposerDebug = Disposer.setDebugMode(Disposer.isDebugMode() && !isStressTest); } @Override @@ -458,8 +459,29 @@ public abstract class KtUsefulTestCase extends TestCase { } } - private boolean isPerformanceTest() { - String name = getName(); - return name != null && name.contains("Performance") || getClass().getName().contains("Performance"); + private static boolean isPerformanceTest(@Nullable String testName, @Nullable String className) { + return testName != null && testName.contains("Performance") || + className != null && className.contains("Performance"); + } + + /** + * @return true for a test which performs A LOT of computations. + * Such test should typically avoid performing expensive checks, e.g. data structure consistency complex validations. + * If you want your test to be treated as "Stress", please mention one of these words in its name: "Stress", "Slow". + * For example: {@code public void testStressPSIFromDifferentThreads()} + */ + + private boolean isStressTest() { + return isStressTest(getName(), getClass().getName()); + } + + private static boolean isStressTest(String testName, String className) { + return isPerformanceTest(testName, className) || + containsStressWords(testName) || + containsStressWords(className); + } + + private static boolean containsStressWords(@Nullable String name) { + return name != null && (name.contains("Stress") || name.contains("Slow")); } } \ No newline at end of file