-
Notifications
You must be signed in to change notification settings - Fork 236
/
single-plugin.groovy
33 lines (26 loc) · 1.1 KB
/
single-plugin.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Run tests that requires plugins enumerated in TEST_ONLY_PLUGINS variable.
//
// 'TEST_ONLY_PLUGINS=git,envinject' run all tests that require git or envinject
// using WithPlugins annotations
import org.junit.runner.Description;
import org.junit.runners.model.Statement;
import org.jenkinsci.test.acceptance.junit.FilterRule.Filter;
import org.jenkinsci.test.acceptance.junit.WithPlugins;
import org.jenkinsci.test.acceptance.update_center.PluginSpec;
import java.lang.annotation.Annotation;
bind Filter toInstance new FilterImpl();
class FilterImpl extends Filter {
public String whySkip(Statement base, Description desc) {
for (annot in getAnnotations(desc, WithPlugins.class)) {
for (value in annot.value()) {
if (testOnlyPlugins().contains(new PluginSpec(value).name)) {
return null;
}
}
}
return "Running only tests for plugins: ${testOnlyPlugins()}";
}
private Collection<String> testOnlyPlugins() {
return (System.getenv("TEST_ONLY_PLUGINS") ?: "").split(",").each { it.trim() };
}
}