Skip to content

Commit 5a41c63

Browse files
ahornaceVladimir Kotal
authored andcommitted
Allow to skip tests requiring Ctags with @ConditionalRun (#2100)
fixes #2088
1 parent 78635c7 commit 5a41c63

39 files changed

+428
-444
lines changed

src/org/opensolaris/opengrok/configuration/RuntimeEnvironment.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919

2020
/*
21-
* Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved.
21+
* Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved.
2222
* Portions Copyright (c) 2017-2018, Chris Fraire <[email protected]>.
2323
*/
2424
package org.opensolaris.opengrok.configuration;
@@ -654,7 +654,7 @@ public boolean validateExuberantCtags() {
654654
Executor executor = new Executor(new String[]{getCtags(), "--version"});
655655
executor.exec(false);
656656
String output = executor.getOutputString();
657-
boolean isUnivCtags = output!=null?output.contains("Universal Ctags"):false;
657+
boolean isUnivCtags = output != null && output.contains("Universal Ctags");
658658
if (output == null || (!output.contains("Exuberant Ctags") && !isUnivCtags)) {
659659
LOGGER.log(Level.SEVERE, "Error: No Exuberant Ctags found in PATH !\n"
660660
+ "(tried running " + "{0}" + ")\n"

test/org/opensolaris/opengrok/analysis/CtagsTest.java

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,27 +25,30 @@
2525
package org.opensolaris.opengrok.analysis;
2626

2727
import java.io.File;
28-
import java.io.IOException;
29-
import org.junit.After;
3028
import org.junit.AfterClass;
3129
import static org.junit.Assert.assertEquals;
3230
import static org.junit.Assert.assertTrue;
33-
import org.junit.Before;
3431
import org.junit.BeforeClass;
32+
import org.junit.Rule;
3533
import org.junit.Test;
34+
import org.opensolaris.opengrok.condition.ConditionalRun;
35+
import org.opensolaris.opengrok.condition.ConditionalRunRule;
36+
import org.opensolaris.opengrok.condition.CtagsInstalled;
3637
import org.opensolaris.opengrok.configuration.RuntimeEnvironment;
3738
import org.opensolaris.opengrok.util.TestRepository;
3839

3940
/**
4041
*
4142
* @author Lubos Kosco
4243
*/
43-
public class CtagsTest {
44+
@ConditionalRun(CtagsInstalled.class)
45+
public class CtagsTest {
46+
4447
private static Ctags ctags;
4548
private static TestRepository repository;
4649

47-
public CtagsTest() {
48-
}
50+
@Rule
51+
public ConditionalRunRule rule = new ConditionalRunRule();
4952

5053
@BeforeClass
5154
public static void setUpClass() throws Exception {
@@ -65,9 +68,6 @@ public static void setUpClass() throws Exception {
6568
String extraOptionsFile =
6669
repository.getSourceRoot() + "/bug19195/ctags.config";
6770
ctags.setCTagsExtraOptionsFile(extraOptionsFile);
68-
69-
assertTrue("No point in running ctags tests without valid ctags",
70-
RuntimeEnvironment.getInstance().validateExuberantCtags());
7171
}
7272

7373
@AfterClass
@@ -78,17 +78,9 @@ public static void tearDownClass() throws Exception {
7878
repository = null;
7979
}
8080

81-
@Before
82-
public void setUp() throws IOException {
83-
}
84-
85-
@After
86-
public void tearDown() {
87-
}
88-
8981
/**
9082
* Helper method that gets the definitions for a file in the repository.
91-
* @param file file name relative to source root
83+
* @param fileName file name relative to source root
9284
* @return the definitions found in the file
9385
*/
9486
private static Definitions getDefs(String fileName) throws Exception {

test/org/opensolaris/opengrok/analysis/JFlexXrefTest.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919

2020
/*
21-
* Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
21+
* Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved.
2222
* Portions Copyright (c) 2017-2018, Chris Fraire <[email protected]>.
2323
*/
2424

@@ -39,6 +39,7 @@
3939
import static org.junit.Assert.assertEquals;
4040
import static org.junit.Assert.assertTrue;
4141
import org.junit.BeforeClass;
42+
import org.junit.Rule;
4243
import org.junit.Test;
4344
import org.opensolaris.opengrok.analysis.c.CXref;
4445
import org.opensolaris.opengrok.analysis.c.CxxXref;
@@ -57,6 +58,9 @@
5758
import org.opensolaris.opengrok.analysis.sql.SQLXref;
5859
import org.opensolaris.opengrok.analysis.tcl.TclXref;
5960
import org.opensolaris.opengrok.analysis.uue.UuencodeXref;
61+
import org.opensolaris.opengrok.condition.ConditionalRun;
62+
import org.opensolaris.opengrok.condition.ConditionalRunRule;
63+
import org.opensolaris.opengrok.condition.CtagsInstalled;
6064
import org.opensolaris.opengrok.configuration.RuntimeEnvironment;
6165
import static org.opensolaris.opengrok.util.CustomAssertions.assertLinesEqual;
6266
import org.opensolaris.opengrok.util.TestRepository;
@@ -70,6 +74,9 @@ public class JFlexXrefTest {
7074
private static Ctags ctags;
7175
private static TestRepository repository;
7276

77+
@Rule
78+
public ConditionalRunRule rule = new ConditionalRunRule();
79+
7380
/**
7481
* This is what we expect to find at the beginning of the first line
7582
* returned by an xref.
@@ -160,6 +167,7 @@ private void bug15890LineCount(JFlexNonXref xref) throws Exception {
160167
* used to cause trouble.
161168
*/
162169
@Test
170+
@ConditionalRun(CtagsInstalled.class)
163171
public void testBug15890Anchor() throws Exception {
164172
bug15890Anchor(CXref.class, "c/bug15890.c");
165173
bug15890Anchor(CxxXref.class, "c/bug15890.c");
@@ -377,6 +385,7 @@ public void testEmptyJavaComment() throws IOException {
377385
}
378386

379387
@Test
388+
@ConditionalRun(CtagsInstalled.class)
380389
public void bug18586() throws IOException, InterruptedException {
381390
String filename = repository.getSourceRoot() + "/sql/bug18586.sql";
382391
Reader in = new InputStreamReader(new FileInputStream(filename), "UTF-8");
@@ -391,6 +400,7 @@ public void bug18586() throws IOException, InterruptedException {
391400
* This originally became a problem after upgrade to JFlex 1.5.0.
392401
*/
393402
@Test
403+
@ConditionalRun(CtagsInstalled.class)
394404
public void unterminatedHeredoc() throws IOException {
395405
JFlexXref xref = new JFlexXref(new ShXref(new StringReader(
396406
"cat << EOF\nunterminated heredoc")));

test/org/opensolaris/opengrok/analysis/c/CAnalyzerFactoryTest.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919

2020
/*
21-
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
21+
* Copyright (c) 2015, 2018 Oracle and/or its affiliates. All rights reserved.
2222
* Portions Copyright (c) 2017-2018, Chris Fraire <[email protected]>.
2323
*/
2424
package org.opensolaris.opengrok.analysis.c;
@@ -40,12 +40,16 @@
4040
import org.apache.lucene.index.IndexableField;
4141
import org.junit.AfterClass;
4242
import org.junit.BeforeClass;
43+
import org.junit.Rule;
4344
import org.junit.Test;
4445
import org.opensolaris.opengrok.analysis.Ctags;
4546
import org.opensolaris.opengrok.analysis.FileAnalyzer;
4647
import org.opensolaris.opengrok.analysis.Scopes;
4748
import org.opensolaris.opengrok.analysis.Scopes.Scope;
4849
import org.opensolaris.opengrok.analysis.StreamSource;
50+
import org.opensolaris.opengrok.condition.ConditionalRun;
51+
import org.opensolaris.opengrok.condition.ConditionalRunRule;
52+
import org.opensolaris.opengrok.condition.CtagsInstalled;
4953
import org.opensolaris.opengrok.configuration.RuntimeEnvironment;
5054
import org.opensolaris.opengrok.search.QueryBuilder;
5155
import org.opensolaris.opengrok.util.TestRepository;
@@ -54,12 +58,16 @@
5458
*
5559
* @author Tomas Kotal
5660
*/
61+
@ConditionalRun(CtagsInstalled.class)
5762
public class CAnalyzerFactoryTest {
5863

5964
private static Ctags ctags;
6065
private static TestRepository repository;
6166
private static FileAnalyzer analyzer;
6267

68+
@Rule
69+
public ConditionalRunRule rule = new ConditionalRunRule();
70+
6371
private static StreamSource getStreamSource(final String fname) {
6472
return new StreamSource() {
6573
@Override

test/org/opensolaris/opengrok/analysis/c/CxxAnalyzerFactoryTest.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919

2020
/*
21-
* Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved.
21+
* Copyright (c) 2015, 2018 Oracle and/or its affiliates. All rights reserved.
2222
* Portions Copyright (c) 2017-2018, Chris Fraire <[email protected]>.
2323
*/
2424
package org.opensolaris.opengrok.analysis.c;
@@ -40,12 +40,16 @@
4040
import org.apache.lucene.index.IndexableField;
4141
import org.junit.AfterClass;
4242
import org.junit.BeforeClass;
43+
import org.junit.Rule;
4344
import org.junit.Test;
4445
import org.opensolaris.opengrok.analysis.Ctags;
4546
import org.opensolaris.opengrok.analysis.FileAnalyzer;
4647
import org.opensolaris.opengrok.analysis.Scopes;
4748
import org.opensolaris.opengrok.analysis.Scopes.Scope;
4849
import org.opensolaris.opengrok.analysis.StreamSource;
50+
import org.opensolaris.opengrok.condition.ConditionalRun;
51+
import org.opensolaris.opengrok.condition.ConditionalRunRule;
52+
import org.opensolaris.opengrok.condition.CtagsInstalled;
4953
import org.opensolaris.opengrok.configuration.RuntimeEnvironment;
5054
import org.opensolaris.opengrok.search.QueryBuilder;
5155
import org.opensolaris.opengrok.util.TestRepository;
@@ -54,12 +58,16 @@
5458
*
5559
* @author Tomas Kotal
5660
*/
61+
@ConditionalRun(CtagsInstalled.class)
5762
public class CxxAnalyzerFactoryTest {
5863

5964
private static Ctags ctags;
6065
private static TestRepository repository;
6166
private static FileAnalyzer analyzer;
6267

68+
@Rule
69+
public ConditionalRunRule rule = new ConditionalRunRule();
70+
6371
private static StreamSource getStreamSource(final String fname) {
6472
return new StreamSource() {
6573
@Override

test/org/opensolaris/opengrok/analysis/clojure/ClojureAnalyzerFactoryTest.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919

2020
/*
21-
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
21+
* Copyright (c) 2016, 2018 Oracle and/or its affiliates. All rights reserved.
2222
* Portions Copyright (c) 2017-2018, Chris Fraire <[email protected]>.
2323
*/
2424
package org.opensolaris.opengrok.analysis.clojure;
@@ -27,11 +27,15 @@
2727
import org.apache.lucene.document.Field;
2828
import org.junit.AfterClass;
2929
import org.junit.BeforeClass;
30+
import org.junit.Rule;
3031
import org.junit.Test;
3132
import org.opensolaris.opengrok.analysis.Ctags;
3233
import org.opensolaris.opengrok.analysis.Definitions;
3334
import org.opensolaris.opengrok.analysis.FileAnalyzer;
3435
import org.opensolaris.opengrok.analysis.StreamSource;
36+
import org.opensolaris.opengrok.condition.ConditionalRun;
37+
import org.opensolaris.opengrok.condition.ConditionalRunRule;
38+
import org.opensolaris.opengrok.condition.CtagsInstalled;
3539
import org.opensolaris.opengrok.configuration.RuntimeEnvironment;
3640
import org.opensolaris.opengrok.search.QueryBuilder;
3741
import org.opensolaris.opengrok.util.TestRepository;
@@ -46,18 +50,21 @@
4650
import static org.junit.Assert.assertTrue;
4751
import static org.junit.Assert.fail;
4852

49-
5053
import static org.opensolaris.opengrok.analysis.AnalyzerGuru.string_ft_nstored_nanalyzed_norms;
5154

5255
/**
5356
* @author Farid Zakaria
5457
*/
58+
@ConditionalRun(CtagsInstalled.class)
5559
public class ClojureAnalyzerFactoryTest {
5660

5761
private static Ctags ctags;
5862
private static TestRepository repository;
5963
private static FileAnalyzer analyzer;
6064

65+
@Rule
66+
public ConditionalRunRule rule = new ConditionalRunRule();
67+
6168
private static StreamSource getStreamSource(final String fname) {
6269
return new StreamSource() {
6370
@Override
@@ -127,5 +134,4 @@ public void testScopeAnalyzer() throws Exception {
127134
assertThat(type[0], is("definition"));
128135
}
129136

130-
131137
}

test/org/opensolaris/opengrok/analysis/csharp/CSharpAnalyzerFactoryTest.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919

2020
/*
21-
* Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved.
21+
* Copyright (c) 2015, 2018 Oracle and/or its affiliates. All rights reserved.
2222
* Portions Copyright (c) 2017-2018, Chris Fraire <[email protected]>.
2323
*/
2424
package org.opensolaris.opengrok.analysis.csharp;
@@ -33,6 +33,7 @@
3333
import org.apache.lucene.document.Field;
3434
import org.junit.AfterClass;
3535
import org.junit.BeforeClass;
36+
import org.junit.Rule;
3637
import org.junit.Test;
3738
import static org.junit.Assert.*;
3839
import static org.opensolaris.opengrok.analysis.AnalyzerGuru.string_ft_nstored_nanalyzed_norms;
@@ -41,6 +42,9 @@
4142
import org.opensolaris.opengrok.analysis.Scopes;
4243
import org.opensolaris.opengrok.analysis.Scopes.Scope;
4344
import org.opensolaris.opengrok.analysis.StreamSource;
45+
import org.opensolaris.opengrok.condition.ConditionalRun;
46+
import org.opensolaris.opengrok.condition.ConditionalRunRule;
47+
import org.opensolaris.opengrok.condition.CtagsInstalled;
4448
import org.opensolaris.opengrok.configuration.RuntimeEnvironment;
4549
import org.opensolaris.opengrok.search.QueryBuilder;
4650
import org.opensolaris.opengrok.util.TestRepository;
@@ -49,12 +53,16 @@
4953
*
5054
* @author Tomas Kotal
5155
*/
56+
@ConditionalRun(CtagsInstalled.class)
5257
public class CSharpAnalyzerFactoryTest {
5358

5459
private static Ctags ctags;
5560
private static TestRepository repository;
5661
private static FileAnalyzer analyzer;
5762

63+
@Rule
64+
public ConditionalRunRule rule = new ConditionalRunRule();
65+
5866
private static StreamSource getStreamSource(final String fname) {
5967
return new StreamSource() {
6068
@Override

0 commit comments

Comments
 (0)