Skip to content

Commit 84f077f

Browse files
committed
convert Main() test to argument parsing test
the results of the indexer run were not checked anyway
1 parent 6460748 commit 84f077f

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

opengrok-indexer/src/test/java/org/opengrok/indexer/index/IndexerTest.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
*/
2525
package org.opengrok.indexer.index;
2626

27+
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
2728
import static org.junit.jupiter.api.Assertions.assertEquals;
2829
import static org.junit.jupiter.api.Assertions.assertFalse;
2930
import static org.junit.jupiter.api.Assertions.assertNotEquals;
@@ -40,6 +41,7 @@
4041
import java.nio.file.Files;
4142
import java.nio.file.Path;
4243
import java.nio.file.Paths;
44+
import java.text.ParseException;
4345
import java.util.ArrayList;
4446
import java.util.Arrays;
4547
import java.util.Collections;
@@ -177,17 +179,14 @@ void testRescanProjects() throws Exception {
177179
assertEquals(p1.getTabSize(), newP1.getTabSize(), "project tabsize");
178180
}
179181

180-
/**
181-
* Test of doIndexerExecution method, of class Indexer.
182-
*/
183182
@Test
184-
void testMain() {
185-
System.out.println("Generate index by using command line options");
183+
void testParseOptions() throws ParseException {
186184
RuntimeEnvironment env = RuntimeEnvironment.getInstance();
187-
String[] argv = {"-S", "-P", "-H", "-Q", "off", "-s",
188-
repository.getSourceRoot(), "-d", repository.getDataRoot(),
185+
String[] argv = {"-S", "-P", "-H", "-Q", "off",
186+
"-s", repository.getSourceRoot(),
187+
"-d", repository.getDataRoot(),
189188
"-v", "-c", env.getCtags()};
190-
Indexer.main(argv);
189+
assertDoesNotThrow(() -> Indexer.parseOptions(argv));
191190
}
192191

193192
private static class MyIndexChangeListener implements IndexChangedListener {
@@ -226,7 +225,6 @@ public void reset() {
226225
/**
227226
* Test indexing w.r.t. setIndexVersionedFilesOnly() setting,
228227
* i.e. if this option is set to true, index only files tracked by SCM.
229-
* @throws Exception
230228
*/
231229
@Test
232230
void testIndexWithSetIndexVersionedFilesOnly() throws Exception {

0 commit comments

Comments
 (0)