treat "Stress" tests as performance

This commit is contained in:
Alexey Kudravtsev
2017-01-18 16:14:05 +03:00
parent e2bc59928a
commit ed8f54e895
3 changed files with 17 additions and 22 deletions
@@ -26,7 +26,6 @@ import com.intellij.codeInsight.daemon.impl.analysis.HighlightInfoHolder;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.Result;
import com.intellij.openapi.application.ex.PathManagerEx;
import com.intellij.openapi.application.impl.ApplicationInfoImpl;
import com.intellij.openapi.command.WriteCommandAction;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.extensions.Extensions;
@@ -55,7 +54,6 @@ public class PsiConcurrencyStressTest extends DaemonAnalyzerTestCase {
@Override
protected void setUp() throws Exception {
ApplicationInfoImpl.setInPerformanceTest(true);
super.setUp();
LanguageLevelProjectExtension.getInstance(myProject).setLanguageLevel(LanguageLevel.JDK_1_5);
@@ -33,6 +33,7 @@ import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.testFramework.*;
import com.intellij.tests.ExternalClasspathClassLoader;
import com.intellij.util.ArrayUtil;
import com.intellij.util.ReflectionUtil;
import junit.framework.*;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -74,8 +75,7 @@ public class TestAll implements Test {
public boolean shouldRun(Description description) {
String className = description.getClassName();
String methodName = description.getMethodName();
return className != null && hasPerformance(className) ||
methodName != null && hasPerformance(methodName);
return UsefulTestCase.isPerformanceTest(methodName, className);
}
@Override
@@ -466,7 +466,7 @@ public class TestAll implements Test {
if (TestRunnerUtil.isJUnit4TestClass(testCaseClass)) {
JUnit4TestAdapter adapter = new JUnit4TestAdapter(testCaseClass);
boolean runEverything = isIncludingPerformanceTestsRun() || isPerformanceTest(testCaseClass) && isPerformanceTestsRun();
boolean runEverything = isIncludingPerformanceTestsRun() || isPerformanceTest(null, testCaseClass) && isPerformanceTestsRun();
if (!runEverything) {
try {
adapter.filter(isPerformanceTestsRun() ? PERFORMANCE_ONLY : NO_PERFORMANCE);
@@ -486,7 +486,7 @@ public class TestAll implements Test {
else {
String name = ((TestCase)test).getName();
if ("warning".equals(name)) return; // Mute TestSuite's "no tests found" warning
if (!isIncludingPerformanceTestsRun() && (isPerformanceTestsRun() ^ (hasPerformance(name) || isPerformanceTest(testCaseClass))))
if (!isIncludingPerformanceTestsRun() && (isPerformanceTestsRun() ^ isPerformanceTest(name, testCaseClass)))
return;
Method method = findTestMethod((TestCase)test);
@@ -525,26 +525,17 @@ public class TestAll implements Test {
}
}
public static boolean shouldIncludePerformanceTestCase(Class aClass) {
return isIncludingPerformanceTestsRun() || isPerformanceTestsRun() || !isPerformanceTest(aClass);
static boolean shouldIncludePerformanceTestCase(Class aClass) {
return isIncludingPerformanceTestsRun() || isPerformanceTestsRun() || !isPerformanceTest(null,aClass);
}
public static boolean isPerformanceTest(Class aClass) {
return hasPerformance(aClass.getSimpleName());
}
private static boolean hasPerformance(String name) {
return name.toLowerCase(Locale.US).contains("performance");
private static boolean isPerformanceTest(String methodName, Class aClass) {
return UsefulTestCase.isPerformanceTest(methodName, aClass.getSimpleName());
}
@Nullable
private static Method safeFindMethod(Class<?> klass, String name) {
try {
return klass.getMethod(name);
}
catch (NoSuchMethodException e) {
return null;
}
return ReflectionUtil.getMethod(klass, name);
}
private static void tryGc(int times) {
@@ -810,8 +810,14 @@ public abstract class UsefulTestCase extends TestCase {
}
public boolean isPerformanceTest() {
String name = getName();
return name != null && name.contains("Performance") || getClass().getName().contains("Performance");
String testName = getName();
String className = getClass().getName();
return isPerformanceTest(testName, className);
}
public static boolean isPerformanceTest(@Nullable String testName, @Nullable String className) {
return testName != null && (testName.contains("Performance") || testName.contains("Stress"))
|| className != null && (className.contains("Performance") || className.contains("Stress"));
}
public static void doPostponedFormatting(final Project project) {