Skip to content

Commit 7a9eac9

Browse files
eas5ahornace
authored andcommitted
Refactored IndexerTest to use conditional test execution
1 parent 9c0a2a8 commit 7a9eac9

File tree

1 file changed

+22
-28
lines changed

1 file changed

+22
-28
lines changed

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

Lines changed: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
import org.junit.jupiter.api.BeforeAll;
5858
import org.junit.jupiter.api.BeforeEach;
5959
import org.junit.jupiter.api.Test;
60+
import org.junit.jupiter.api.condition.EnabledIf;
6061
import org.opengrok.indexer.analysis.AnalyzerFactory;
6162
import org.opengrok.indexer.analysis.AnalyzerGuru;
6263
import org.opengrok.indexer.condition.EnabledForRepository;
@@ -451,39 +452,32 @@ public void testIncrementalIndexAddRemoveFile() throws Exception {
451452
* @throws Exception
452453
*/
453454
@Test
455+
@EnabledIf("mkfifoInPath")
454456
public void testBug11896() throws Exception {
457+
RuntimeEnvironment env = RuntimeEnvironment.getInstance();
458+
env.setSourceRoot(repository.getSourceRoot());
459+
env.setDataRoot(repository.getDataRoot());
460+
Executor executor;
455461

456-
boolean test = true;
457-
if (FileUtilities.findProgInPath("mkfifo") == null) {
458-
System.out.println("Error: mkfifo not found in PATH !\n");
459-
test = false;
460-
}
461-
462-
if (test) {
463-
RuntimeEnvironment env = RuntimeEnvironment.getInstance();
464-
env.setSourceRoot(repository.getSourceRoot());
465-
env.setDataRoot(repository.getDataRoot());
466-
Executor executor;
467-
468-
executor = new Executor(new String[] {"mkdir", "-p", repository.getSourceRoot() + "/testBug11896"});
469-
executor.exec(true);
462+
executor = new Executor(new String[] {"mkdir", "-p", repository.getSourceRoot() + "/testBug11896"});
463+
executor.exec(true);
470464

471-
executor = new Executor(new String[] {"mkfifo", repository.getSourceRoot() + "/testBug11896/FIFO"});
472-
executor.exec(true);
465+
executor = new Executor(new String[] {"mkfifo", repository.getSourceRoot() + "/testBug11896/FIFO"});
466+
executor.exec(true);
473467

474-
Project project = new Project("testBug11896");
475-
project.setPath("/testBug11896");
476-
IndexDatabase idb = new IndexDatabase(project);
477-
assertNotNull(idb);
478-
MyIndexChangeListener listener = new MyIndexChangeListener();
479-
idb.addIndexChangedListener(listener);
480-
System.out.println("Trying to index a special file - FIFO in this case.");
481-
idb.update();
482-
assertEquals(0, listener.files.size());
468+
Project project = new Project("testBug11896");
469+
project.setPath("/testBug11896");
470+
IndexDatabase idb = new IndexDatabase(project);
471+
assertNotNull(idb);
472+
MyIndexChangeListener listener = new MyIndexChangeListener();
473+
idb.addIndexChangedListener(listener);
474+
System.out.println("Trying to index a special file - FIFO in this case.");
475+
idb.update();
476+
assertEquals(0, listener.files.size());
477+
}
483478

484-
} else {
485-
System.out.println("Skipping test for bug 11896. Could not find a mkfifo in path.");
486-
}
479+
boolean mkfifoInPath() {
480+
return FileUtilities.findProgInPath("mkfifo") != null;
487481
}
488482

489483
/**

0 commit comments

Comments
 (0)