use of org.opensolaris.opengrok.configuration.RuntimeEnvironment in project OpenGrok by OpenGrok.
the class IndexerTest method testRemoveFileOnFileChange.
/**
* Test that reindex after changing a file does not wipe out history index
* for this file. This is important for the incremental history indexing.
* @throws Exception
*/
@Test
@ConditionalRun(condition = RepositoryInstalled.MercurialInstalled.class)
public void testRemoveFileOnFileChange() throws Exception {
RuntimeEnvironment env = RuntimeEnvironment.getInstance();
if (!env.validateExuberantCtags()) {
System.out.println("Skipping test due to no ctags");
}
TestRepository testrepo = new TestRepository();
testrepo.create(HistoryGuru.class.getResourceAsStream("repositories.zip"));
env.setSourceRoot(testrepo.getSourceRoot());
env.setDataRoot(testrepo.getDataRoot());
env.setRepositories(testrepo.getSourceRoot());
// create index
Project project = new Project("mercurial", "/mercurial");
IndexDatabase idb = new IndexDatabase(project);
assertNotNull(idb);
RemoveIndexChangeListener listener = new RemoveIndexChangeListener();
idb.addIndexChangedListener(listener);
idb.update(parallelizer);
Assert.assertEquals(5, listener.filesToAdd.size());
listener.reset();
// Change a file so that it gets picked up by the indexer.
Thread.sleep(1100);
File bar = new File(testrepo.getSourceRoot() + File.separator + "mercurial", "bar.txt");
Assert.assertTrue(bar.exists());
FileWriter fw = new FileWriter(bar, true);
BufferedWriter bw = new BufferedWriter(fw);
bw.write("foo\n");
bw.close();
fw.close();
// reindex
idb.update(parallelizer);
// Make sure that the file was actually processed.
assertEquals(1, listener.removedFiles.size());
assertEquals(1, listener.filesToAdd.size());
assertEquals("/mercurial/bar.txt", listener.removedFiles.peek());
testrepo.destroy();
}
use of org.opensolaris.opengrok.configuration.RuntimeEnvironment in project OpenGrok by OpenGrok.
the class IndexerTest method testDefaultProjectsNonExistent.
/**
* Should discard the non existing project.
*
* @throws Exception
*/
@Test
public void testDefaultProjectsNonExistent() throws Exception {
RuntimeEnvironment env = RuntimeEnvironment.getInstance();
env.setSourceRoot(repository.getSourceRoot());
env.setDataRoot(repository.getDataRoot());
env.setHistoryEnabled(false);
Indexer.getInstance().prepareIndexer(env, true, true, new TreeSet<>(Arrays.asList(new String[] { "/lisp", "/pascal", "/perl", "/data", "/no-project-x32ds1" })), false, false, null, null, new ArrayList<>(), false);
assertEquals(4, env.getDefaultProjects().size());
assertEquals(new TreeSet<>(Arrays.asList(new String[] { "/lisp", "/pascal", "/perl", "/data" })), env.getDefaultProjects().stream().map((Project p) -> '/' + p.getName()).collect(Collectors.toSet()));
}
use of org.opensolaris.opengrok.configuration.RuntimeEnvironment in project OpenGrok by OpenGrok.
the class IndexerTest method testBug3430.
@Test
public void testBug3430() throws Exception {
RuntimeEnvironment env = RuntimeEnvironment.getInstance();
env.setSourceRoot(repository.getSourceRoot());
env.setDataRoot(repository.getDataRoot());
if (env.validateExuberantCtags()) {
Project project = new Project("bug3430");
project.setPath("/bug3430");
IndexDatabase idb = new IndexDatabase(project);
assertNotNull(idb);
MyIndexChangeListener listener = new MyIndexChangeListener();
idb.addIndexChangedListener(listener);
idb.update(parallelizer);
assertEquals(1, listener.files.size());
} else {
System.out.println("Skipping test. Could not find a ctags I could use in path.");
}
}
use of org.opensolaris.opengrok.configuration.RuntimeEnvironment in project OpenGrok by OpenGrok.
the class TestRepository method createEmpty.
public void createEmpty() throws IOException {
RuntimeEnvironment env = RuntimeEnvironment.getInstance();
sourceRoot = FileUtilities.createTemporaryDirectory("source");
dataRoot = FileUtilities.createTemporaryDirectory("data");
env.setSourceRoot(sourceRoot.getAbsolutePath());
env.setDataRoot(dataRoot.getAbsolutePath());
}
use of org.opensolaris.opengrok.configuration.RuntimeEnvironment in project OpenGrok by OpenGrok.
the class DirectoryListingTest method setUp.
@Before
public void setUp() throws Exception {
directory = FileUtilities.createTemporaryDirectory("directory");
entries = new FileEntry[3];
entries[0] = new FileEntry("foo.c", "foo.c", 0, 112);
entries[1] = new FileEntry("bar.h", "bar.h", Long.MAX_VALUE, 0);
// Will test getSimplifiedPath() behavior for ignored directories.
// Use DIRECTORY_INTERNAL_SIZE value for length so it is checked as the directory
// should contain "-" (DIRECTORY_SIZE_PLACEHOLDER) string.
entries[2] = new FileEntry("subdir", "subdir/", 0, Arrays.asList(new FileEntry[] { new FileEntry("SCCS", "SCCS/", 0, Arrays.asList(new FileEntry[] { new FileEntry("version", "version", 0, 312) })) }));
for (FileEntry entry : entries) {
entry.create();
}
// Create the entry that will be ignored separately.
FileEntry hgtags = new FileEntry(".hgtags", ".hgtags", 0, 1);
hgtags.create();
// Need to populate list of ignored entries for all repository types.
RuntimeEnvironment env = RuntimeEnvironment.getInstance();
RepositoryFactory.initializeIgnoredNames(env);
}
Aggregations