Skip to content

Commit 9ee3db4

Browse files
committed
Fix tests on Maven.
Use absolute paths so that the tests work regardless of the directory from which they are started.
1 parent e7cd132 commit 9ee3db4

File tree

3 files changed

+23
-9
lines changed

3 files changed

+23
-9
lines changed

opengrok-indexer/build.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ information: Portions Copyright [yyyy] [name of copyright owner]
1818
1919
CDDL HEADER END
2020
21-
Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
21+
Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
2222
2323
-->
2424
<project name="OpenGrok" default="jar" basedir=".">
@@ -30,7 +30,7 @@ Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
3030

3131
<property name="test.repositories" value="../testdata/repositories"/>
3232
<property name="test.sources" value="../testdata/sources"/>
33-
<property name="test.cvs" value="${test.repositories}/cvs"/>
33+
<property name="test.cvs" value="${test.repositories}/cvs_test"/>
3434
<property name="test.cvs.repo" value="${test.cvs}/cvsrepo"/>
3535
<property name="test.cvs.root" value="${test.cvs}/cvsroot"/>
3636
<property name="test.hg" value="${test.repositories}/mercurial"/>

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

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

2020
/*
21-
* Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
21+
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
2222
*/
2323

2424
package org.opensolaris.opengrok.analysis;
@@ -50,27 +50,30 @@ public static void setUpClass() throws Exception {
5050
ctags = new Ctags();
5151
ctags.setBinary(RuntimeEnvironment.getInstance().getCtags());
5252

53+
repository = new TestRepository();
54+
repository.create(CtagsTest.class.getResourceAsStream(
55+
"/org/opensolaris/opengrok/index/source.zip"));
56+
5357
/*
5458
* This setting is only needed for bug19195 but it does not seem
5559
* that it is possible to specify it just for single test case.
5660
* The config file contains assembly specific settings so it should
5761
* not be harmful to other test cases.
5862
*/
59-
String extraOptionsFile = "testdata/sources/bug19195/ctags.config";
63+
String extraOptionsFile =
64+
repository.getSourceRoot() + "/bug19195/ctags.config";
6065
ctags.setCTagsExtraOptionsFile(extraOptionsFile);
6166

6267
assertTrue("No point in running ctags tests without valid ctags",
6368
RuntimeEnvironment.getInstance().validateExuberantCtags());
64-
repository = new TestRepository();
65-
repository.create(CtagsTest.class.getResourceAsStream(
66-
"/org/opensolaris/opengrok/index/source.zip"));
6769
}
6870

6971
@AfterClass
7072
public static void tearDownClass() throws Exception {
7173
ctags.close();
7274
ctags = null;
7375
repository.destroy();
76+
repository = null;
7477
}
7578

7679
@Before

test/org/opensolaris/opengrok/analysis/document/TroffAnalyzerTest.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import org.opensolaris.opengrok.web.Util;
4242
import static org.junit.Assert.*;
4343
import org.opensolaris.opengrok.analysis.StreamSource;
44+
import org.opensolaris.opengrok.util.TestRepository;
4445

4546
/**
4647
* @author Jens Elkner
@@ -50,19 +51,24 @@ public class TroffAnalyzerTest {
5051
private static TroffAnalyzerFactory factory;
5152
private static TroffAnalyzer analyzer;
5253
private static String content;
54+
private static TestRepository repository;
5355

5456
/**
5557
* Test method for {@link org.opensolaris.opengrok.analysis.document
5658
* .TroffAnalyzer#TroffAnalyzer(org.opensolaris.opengrok.analysis.FileAnalyzerFactory)}.
5759
*/
5860
@BeforeClass
59-
public static void setUpBeforeClass() {
61+
public static void setUpBeforeClass() throws Exception {
6062
factory = new TroffAnalyzerFactory();
6163
assertNotNull(factory);
6264
analyzer = new TroffAnalyzer(factory);
6365
assertNotNull(analyzer);
66+
repository = new TestRepository();
67+
repository.create(TroffAnalyzerTest.class.getResourceAsStream(
68+
"/org/opensolaris/opengrok/index/source.zip"));
69+
6470
String file = System.getProperty("opengrok.test.troff.doc",
65-
"testdata/sources/document/foobar.1");
71+
repository.getSourceRoot() + "/document/foobar.1");
6672
File f = new File(file);
6773
if (!(f.canRead() && f.isFile())) {
6874
fail("troff testfile " + f + " not found");
@@ -77,6 +83,11 @@ public static void setUpBeforeClass() {
7783
*/
7884
@AfterClass
7985
public static void tearDownAfterClass() throws Exception {
86+
factory = null;
87+
analyzer = null;
88+
content = null;
89+
repository.destroy();
90+
repository = null;
8091
}
8192

8293
/**

0 commit comments

Comments
 (0)