use of org.opengrok.indexer.configuration.RuntimeEnvironment in project OpenGrok by OpenGrok.
the class IndexerTest method testSetRepositories.
@Test
@EnabledForRepository(MERCURIAL)
void testSetRepositories() throws Exception {
RuntimeEnvironment env = RuntimeEnvironment.getInstance();
TestRepository testrepo = new TestRepository();
testrepo.create(HistoryGuru.class.getResource("/repositories"));
env.setSourceRoot(testrepo.getSourceRoot());
env.setRepositories(testrepo.getSourceRoot());
assertEquals(7, env.getRepositories().size());
String[] repoNames = { "mercurial", "git" };
env.setRepositories(Arrays.stream(repoNames).map(t -> Paths.get(env.getSourceRootPath(), t).toString()).distinct().toArray(String[]::new));
assertEquals(2, env.getRepositories().size());
}
use of org.opengrok.indexer.configuration.RuntimeEnvironment in project OpenGrok by OpenGrok.
the class IndexerTest method testDefaultProjectsAll.
/**
* Should include all projects in the source root.
* @throws Exception
*/
@Test
void testDefaultProjectsAll() throws Exception {
RuntimeEnvironment env = RuntimeEnvironment.getInstance();
env.setSourceRoot(repository.getSourceRoot());
env.setDataRoot(repository.getDataRoot());
env.setHistoryEnabled(false);
Set<String> defaultProjects = new TreeSet<>();
defaultProjects.add("/c");
defaultProjects.add("/data");
defaultProjects.add("__all__");
defaultProjects.add("/no-project-x32ds1");
Indexer.getInstance().prepareIndexer(env, true, true, false, null, null);
env.setDefaultProjectsFromNames(defaultProjects);
Set<String> projects = new TreeSet<>(Arrays.asList(new File(repository.getSourceRoot()).list()));
assertEquals(projects.size(), env.getDefaultProjects().size());
assertEquals(projects, env.getDefaultProjects().stream().map(Project::getName).collect(Collectors.toSet()));
}
use of org.opengrok.indexer.configuration.RuntimeEnvironment in project OpenGrok by OpenGrok.
the class IndexerTest method testIncrementalIndexAddRemoveFile.
/**
* Test IndexChangedListener behavior in repository with invalid files.
* @throws Exception
*/
@Test
void testIncrementalIndexAddRemoveFile() throws Exception {
RuntimeEnvironment env = RuntimeEnvironment.getInstance();
env.setSourceRoot(repository.getSourceRoot());
env.setDataRoot(repository.getDataRoot());
String ppath = "/bug3430";
Project project = new Project("bug3430", ppath);
IndexDatabase idb = new IndexDatabase(project);
assertNotNull(idb);
MyIndexChangeListener listener = new MyIndexChangeListener();
idb.addIndexChangedListener(listener);
idb.update();
assertEquals(1, listener.files.size());
listener.reset();
repository.addDummyFile(ppath);
idb.update();
assertEquals(1, listener.files.size(), "No new file added");
repository.removeDummyFile(ppath);
idb.update();
assertEquals(1, listener.files.size(), "(added)files changed unexpectedly");
assertEquals(1, listener.removedFiles.size(), "Didn't remove the dummy file");
assertEquals(listener.files.peek(), listener.removedFiles.peek(), "Should have added then removed the same file");
}
use of org.opengrok.indexer.configuration.RuntimeEnvironment in project OpenGrok by OpenGrok.
the class IndexerTest method testIndexWithSetIndexVersionedFilesOnly.
/**
* Test indexing w.r.t. setIndexVersionedFilesOnly() setting,
* i.e. if this option is set to true, index only files tracked by SCM.
* @throws Exception
*/
@Test
void testIndexWithSetIndexVersionedFilesOnly() throws Exception {
RuntimeEnvironment env = RuntimeEnvironment.getInstance();
env.setSourceRoot(repository.getSourceRoot());
env.setDataRoot(repository.getDataRoot());
env.setRepositories(repository.getSourceRoot());
List<RepositoryInfo> repos = env.getRepositories();
Repository r = null;
for (RepositoryInfo ri : repos) {
if (ri.getDirectoryName().equals(repository.getSourceRoot() + "/rfe2575")) {
r = RepositoryFactory.getRepository(ri, CommandTimeoutType.INDEXER);
break;
}
}
if (r != null && r.isWorking()) {
Project project = new Project("rfe2575");
project.setPath("/rfe2575");
IndexDatabase idb = new IndexDatabase(project);
assertNotNull(idb);
MyIndexChangeListener listener = new MyIndexChangeListener();
idb.addIndexChangedListener(listener);
idb.update();
assertEquals(2, listener.files.size());
repository.purgeData();
RuntimeEnvironment.getInstance().setIndexVersionedFilesOnly(true);
idb = new IndexDatabase(project);
listener = new MyIndexChangeListener();
idb.addIndexChangedListener(listener);
idb.update();
assertEquals(1, listener.files.size());
RuntimeEnvironment.getInstance().setIndexVersionedFilesOnly(false);
} else {
System.out.println("Skipping test. Repository for rfe2575 not found or an sccs I could use in path.");
}
}
use of org.opengrok.indexer.configuration.RuntimeEnvironment in project OpenGrok by OpenGrok.
the class CtagsUtilTest method getLanguages.
@Test
public void getLanguages() {
RuntimeEnvironment env = RuntimeEnvironment.getInstance();
List<String> result = CtagsUtil.getLanguages(env.getCtags());
assertNotNull(result, "should get Ctags languages");
assertTrue(result.contains("C++"), "Ctags languages should contains C++");
// Test that the [disabled] tag is stripped for OldC.
assertTrue(result.contains("OldC"), "Ctags languages should contains OldC");
}
Aggregations