From eedbc056fd6ace5978cdadd38eb98ad3179af891 Mon Sep 17 00:00:00 2001 From: Maxim Shafirov Date: Tue, 13 Dec 2011 21:01:59 +0400 Subject: [PATCH] Ability to filter community tests from ultimate tests run --- .../intellij/tests/ExternalClasspathClassLoader.java | 10 ++++++++++ platform/testFramework/src/com/intellij/TestAll.java | 12 +++++++++++- .../src/com/intellij/TestCaseLoader.java | 1 + 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/platform/testFramework/bootstrap/src/com/intellij/tests/ExternalClasspathClassLoader.java b/platform/testFramework/bootstrap/src/com/intellij/tests/ExternalClasspathClassLoader.java index 74fd14186ca2..c3530cc476d7 100644 --- a/platform/testFramework/bootstrap/src/com/intellij/tests/ExternalClasspathClassLoader.java +++ b/platform/testFramework/bootstrap/src/com/intellij/tests/ExternalClasspathClassLoader.java @@ -60,6 +60,16 @@ public class ExternalClasspathClassLoader extends URLClassLoader { final String classPathFilePath = System.getProperty("classpath.file"); return classPathFilePath != null ? parseUrls(classPathFilePath) : null; } + + public static String[] getExcludeRoots() { + try { + final String classPathFilePath = System.getProperty("exclude.tests.roots.file"); + return classPathFilePath != null ? parseUrls(classPathFilePath) : null; + } + catch (Exception e) { + return new String[0]; + } + } public static void install() { try { diff --git a/platform/testFramework/src/com/intellij/TestAll.java b/platform/testFramework/src/com/intellij/TestAll.java index e21d4140dec1..bde8685224b6 100644 --- a/platform/testFramework/src/com/intellij/TestAll.java +++ b/platform/testFramework/src/com/intellij/TestAll.java @@ -25,6 +25,7 @@ package com.intellij; import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.vfs.VfsUtil; import com.intellij.testFramework.*; @@ -43,7 +44,9 @@ import java.lang.reflect.Modifier; import java.net.URL; import java.net.URLClassLoader; import java.util.Arrays; +import java.util.LinkedHashSet; import java.util.List; +import java.util.Set; @SuppressWarnings({"HardCodedStringLiteral", "CallToPrintStackTrace", "UseOfSystemOutOrSystemErr"}) public class TestAll implements Test { @@ -356,8 +359,15 @@ public class TestAll implements Test { System.out.println("Collecting tests from roots specified by test.roots property: " + testRoots); return testRoots.split(";"); } - final String[] roots = ExternalClasspathClassLoader.getRoots(); + String[] roots = ExternalClasspathClassLoader.getRoots(); if (roots != null) { + if (Comparing.equal(System.getProperty(TestCaseLoader.SKIP_COMMUNITY_TESTS), "true")) { + System.out.println("Skipping community tests"); + Set set = new LinkedHashSet(Arrays.asList(roots)); + set.removeAll(Arrays.asList(ExternalClasspathClassLoader.getExcludeRoots())); + roots = set.toArray(new String[set.size()]); + } + System.out.println("Collecting tests from roots specified by classpath.file property: " + Arrays.toString(roots)); return roots; } diff --git a/platform/testFramework/src/com/intellij/TestCaseLoader.java b/platform/testFramework/src/com/intellij/TestCaseLoader.java index 816161729755..78b3484738aa 100644 --- a/platform/testFramework/src/com/intellij/TestCaseLoader.java +++ b/platform/testFramework/src/com/intellij/TestCaseLoader.java @@ -47,6 +47,7 @@ public class TestCaseLoader { private static final String TARGET_TEST_PATTERNS = "idea.test.patterns"; public static final String PERFORMANCE_TESTS_ONLY_FLAG = "idea.performance.tests"; + public static final String SKIP_COMMUNITY_TESTS = "idea.skip.community.tests"; private final List myClassList = new ArrayList(); private Class myFirstTestClass;