Skip to content

Commit 2ebeb8f

Browse files
ahornaceVladimir Kotal
authored and
Vladimir Kotal
committed
Remove build dependency on svn
fixes #2112
1 parent 0ddc795 commit 2ebeb8f

File tree

8 files changed

+80
-137
lines changed

8 files changed

+80
-137
lines changed

Diff for: .gitattributes

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
*.rtf diff=astextplain
1414
*.RTF diff=astextplain
1515

16-
/testdata/svndump/svnlog.dump text eol=lf
16+
/opengrok-indexer/src/test/resources/history/svnlog.dump text eol=lf

Diff for: opengrok-indexer/build.xml

+7-88
Original file line numberDiff line numberDiff line change
@@ -22,47 +22,20 @@ Copyright (c) 2007, 2021, Oracle and/or its affiliates. All rights reserved.
2222
Portions Copyright (c) 2020, Chris Fraire <[email protected]>.
2323
2424
-->
25-
<project name="OpenGrok" default="jar" basedir=".">
26-
<description>Builds, tests, and runs the project opengrok.</description>
27-
28-
<property name="distname" value="opengrok"/>
25+
<project name="OpenGrok" default="-post-compile-test" basedir=".">
26+
<description>Builds testdata for indexer.</description>
2927

3028
<property name="build.classes.dir" value="target/classes"/>
3129

3230
<property name="test.repositories" value="../testdata/repositories"/>
3331
<property name="test.sources" value="../testdata/sources"/>
34-
<property name="test.svndump" value="../testdata/svndump"/>
35-
<property name="test.plugins" value="../testdata/plugins"/>
36-
<property name="test.cvs" value="${test.repositories}/cvs_test"/>
37-
<property name="test.cvs.repo" value="${test.cvs}/cvsrepo"/>
38-
<property name="test.cvs.root" value="${test.cvs}/cvsroot"/>
3932
<property name="test.bk" value="${test.repositories}/bitkeeper"/>
4033
<property name="test.bzr" value="${test.repositories}/bazaar"/>
4134
<property name="test.hg" value="${test.repositories}/mercurial"/>
4235
<property name="test.git" value="${test.repositories}/git"/>
43-
<property name="test.svn" value="${test.repositories}/svn"/>
44-
<property name="test.svn2" value="${test.repositories}/subversion"/>
45-
<property name="build.test.reposroots" value="target/reposroot"/>
4636
<property name="build.test.classes.dir" value="target/test-classes"/>
4737

48-
49-
<path id="lib.search.path">
50-
<pathelement path="${user.home}/.ant/lib"/>
51-
<pathelement path="${java.class.path}"/>
52-
<pathelement path="lib"/>
53-
<pathelement path="../lib"/>
54-
</path>
55-
56-
<property name="git" value="git"/>
57-
5838
<target name="-post-compile-test">
59-
<antcall target="-create-svn-repository"/>
60-
61-
<!-- Change root in CVS test repository -->
62-
<!-- Strange indentation in line two levels below to get newline correctly -->
63-
<concat destfile="${test.cvs.repo}/CVS/Root" append="no" force="yes" eol="unix">${basedir}/${test.cvs.root}/
64-
</concat>
65-
6639
<!-- Generate ZIP files used for unit testing git/.git are renamed -->
6740
<copy todir="${test.git}/.git">
6841
<fileset dir="${test.git}/git"/>
@@ -76,14 +49,14 @@ Portions Copyright (c) 2020, Chris Fraire <[email protected]>.
7649

7750
<!-- Generate ZIP files used for unit testing bitkeeper/.bk are renamed -->
7851
<copy todir="${test.bk}/.bk">
79-
<!--
80-
The bk directory contains SCCS subdirectory which we want to
81-
include so disable default excludes.
82-
-->
52+
<!--
53+
The bk directory contains SCCS subdirectory which we want to
54+
include so disable default excludes.
55+
-->
8356
<fileset dir="${test.bk}/bk" defaultexcludes="no"/>
8457
</copy>
8558

86-
<!-- Generate ZIP files used for unit testing bzr/.bzr are renamed -->
59+
<!-- Generate ZIP files used for unit testing bzr/.bzr are renamed -->
8760
<copy todir="${test.bzr}/.bzr">
8861
<fileset dir="${test.bzr}/bzr"/>
8962
</copy>
@@ -101,67 +74,13 @@ Portions Copyright (c) 2020, Chris Fraire <[email protected]>.
10174
<antcall target="-delete-generated-repository-files"/>
10275
</target>
10376

104-
<target name="-create-svn-repository">
105-
<delete dir="${test.svn}"/>
106-
<delete dir="${test.svn2}"/>
107-
<delete dir="${build.test.reposroots}/svn"/>
108-
<delete dir="${build.test.reposroots}/svn2"/>
109-
<mkdir dir="${build.test.reposroots}"/>
110-
<exec executable="svnadmin" failifexecutionfails="true">
111-
<arg value="create"/>
112-
<arg value="${build.test.reposroots}/svn"/>
113-
</exec>
114-
115-
<!-- need absolute path for svn url -->
116-
<pathconvert property="test.svn.url">
117-
<map from="" to="file:///"/>
118-
<path location="${build.test.reposroots}/svn"/>
119-
</pathconvert>
120-
<pathconvert property="test.svn.url2">
121-
<map from="" to="file:///"/>
122-
<path location="${build.test.reposroots}/svn2"/>
123-
</pathconvert>
124-
125-
<exec executable="svn" failifexecutionfails="false">
126-
<arg value="import"/>
127-
<arg value="${test.sources}"/>
128-
<arg value="${test.svn.url}"/>
129-
<arg value="-m"/>
130-
<arg value="Initial import"/>
131-
</exec>
132-
<exec executable="svn" failifexecutionfails="false">
133-
<arg value="checkout"/>
134-
<arg value="${test.svn.url}"/>
135-
<arg value="${test.svn}"/>
136-
</exec>
137-
138-
<exec executable="svnadmin" failifexecutionfails="true">
139-
<arg value="create"/>
140-
<arg value="${build.test.reposroots}/svn2"/>
141-
</exec>
142-
143-
<exec executable="svnadmin" input="${test.svndump}/svnlog.dump" failifexecutionfails="true">
144-
<arg value="load"/>
145-
<arg value="${build.test.reposroots}/svn2"/>
146-
</exec>
147-
148-
<exec executable="svn" failifexecutionfails="false">
149-
<arg value="checkout"/>
150-
<arg value="${test.svn.url2}"/>
151-
<arg value="${test.svn2}"/>
152-
</exec>
153-
</target>
154-
15577
<!-- clean up generated test repositories -->
15678
<target name="-delete-generated-repository-files">
15779
<delete dir="${test.bk}/.bk"/>
15880
<delete dir="${test.bzr}/.bzr"/>
15981
<delete dir="${test.hg}/.hg"/>
16082
<delete file="${test.hg}/.hgignore"/>
16183
<delete dir="${test.git}/.git"/>
162-
<delete dir="${test.svn}"/>
163-
<delete dir="${test.svn2}"/>
164-
<delete file="${test.cvs.repo}/CVS/Root"/>
16584
</target>
16685

16786
</project>

Diff for: opengrok-indexer/src/test/java/org/opengrok/indexer/history/FileHistoryCacheTest.java

+42-10
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
import java.io.FileOutputStream;
4040
import java.io.IOException;
4141
import java.nio.charset.StandardCharsets;
42+
import java.nio.file.Files;
43+
import java.nio.file.Path;
4244
import java.nio.file.Paths;
4345
import java.util.Date;
4446
import java.util.Iterator;
@@ -60,6 +62,7 @@
6062
import org.opengrok.indexer.configuration.Filter;
6163
import org.opengrok.indexer.configuration.IgnoredNames;
6264
import org.opengrok.indexer.configuration.RuntimeEnvironment;
65+
import org.opengrok.indexer.util.IOUtils;
6366
import org.opengrok.indexer.util.TandemPath;
6467
import org.opengrok.indexer.util.TestRepository;
6568

@@ -68,7 +71,7 @@
6871
*
6972
* @author Vladimir Kotal
7073
*/
71-
public class FileHistoryCacheTest {
74+
class FileHistoryCacheTest {
7275

7376
private static final String SVN_DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'";
7477

@@ -159,7 +162,7 @@ private void assertSameEntry(HistoryEntry expected, HistoryEntry actual, boolean
159162
*/
160163
@EnabledForRepository(MERCURIAL)
161164
@Test
162-
public void testStoreAndGetNotRenamed() throws Exception {
165+
void testStoreAndGetNotRenamed() throws Exception {
163166
File reposRoot = new File(repositories.getSourceRoot(), "mercurial");
164167
Repository repo = RepositoryFactory.getRepository(reposRoot);
165168
History historyToStore = repo.getHistory(reposRoot);
@@ -185,7 +188,7 @@ public void testStoreAndGetNotRenamed() throws Exception {
185188
*/
186189
@EnabledForRepository(MERCURIAL)
187190
@Test
188-
public void testStoreAndGetIncrementalTags() throws Exception {
191+
void testStoreAndGetIncrementalTags() throws Exception {
189192
// Enable tagging of history entries.
190193
env.setTagsEnabled(true);
191194

@@ -260,7 +263,7 @@ public void testStoreAndGetIncrementalTags() throws Exception {
260263
@Test
261264
@EnabledOnOs({OS.LINUX, OS.MAC, OS.SOLARIS, OS.AIX, OS.OTHER})
262265
@EnabledForRepository(MERCURIAL)
263-
public void testStoreAndGet() throws Exception {
266+
void testStoreAndGet() throws Exception {
264267
File reposRoot = new File(repositories.getSourceRoot(), "mercurial");
265268

266269
// The test expects support for renamed files.
@@ -382,7 +385,7 @@ public void testStoreAndGet() throws Exception {
382385
@EnabledOnOs({OS.LINUX, OS.MAC, OS.SOLARIS, OS.AIX, OS.OTHER})
383386
@EnabledForRepository(MERCURIAL)
384387
@Test
385-
public void testRenameFileThenDoIncrementalReindex() throws Exception {
388+
void testRenameFileThenDoIncrementalReindex() throws Exception {
386389
File reposRoot = new File(repositories.getSourceRoot(), "mercurial");
387390
History updatedHistory;
388391

@@ -504,7 +507,7 @@ public void testRenameFileThenDoIncrementalReindex() throws Exception {
504507
@EnabledOnOs({OS.LINUX, OS.MAC, OS.SOLARIS, OS.AIX, OS.OTHER})
505508
@EnabledForRepository(MERCURIAL)
506509
@Test
507-
public void testRenamedFilePlusChangesBranched() throws Exception {
510+
void testRenamedFilePlusChangesBranched() throws Exception {
508511
File reposRoot = new File(repositories.getSourceRoot(), "mercurial");
509512
History updatedHistory;
510513

@@ -620,7 +623,9 @@ public void testRenamedFilePlusChangesBranched() throws Exception {
620623
*/
621624
@EnabledForRepository(SUBVERSION)
622625
@Test
623-
public void testMultipleRenamedFiles() throws Exception {
626+
void testMultipleRenamedFiles() throws Exception {
627+
createSvnRepository();
628+
624629
File reposRoot = new File(repositories.getSourceRoot(), "subversion");
625630
History updatedHistory;
626631

@@ -669,6 +674,31 @@ public void testMultipleRenamedFiles() throws Exception {
669674
assertSameEntries(histConstruct.getHistoryEntries(), updatedHistory.getHistoryEntries(), false);
670675
}
671676

677+
private void createSvnRepository() throws Exception {
678+
var svnLog = FileHistoryCacheTest.class.getResource("/history/svnlog.dump");
679+
Path tempDir = Files.createTempDirectory("opengrok");
680+
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
681+
try {
682+
IOUtils.removeRecursive(tempDir);
683+
} catch (IOException e) {
684+
// ignore
685+
}
686+
}));
687+
String repo = tempDir.resolve("svn-repo").toString();
688+
var svnCreateRepoProcess = new ProcessBuilder("svnadmin", "create", repo).start();
689+
assertEquals(0, svnCreateRepoProcess.waitFor());
690+
691+
var svnLoadRepoFromDumpProcess = new ProcessBuilder("svnadmin", "load", repo)
692+
.redirectInput(Paths.get(svnLog.toURI()).toFile())
693+
.start();
694+
assertEquals(0, svnLoadRepoFromDumpProcess.waitFor());
695+
696+
var svnCheckoutProcess = new ProcessBuilder("svn", "checkout", Path.of(repo).toUri().toString(),
697+
Path.of(repositories.getSourceRoot()).resolve("subversion").toString())
698+
.start();
699+
assertEquals(0, svnCheckoutProcess.waitFor());
700+
}
701+
672702
private void changeFileAndCommit(Git git, File file, String comment) throws Exception {
673703
String authorName = "Foo Bar";
674704
String authorEmail = "[email protected]";
@@ -748,7 +778,9 @@ void testRenamedFileHistoryWithPerPartes(int maxCount) throws Exception {
748778
*/
749779
@EnabledForRepository(SUBVERSION)
750780
@Test
751-
public void testRenamedFile() throws Exception {
781+
void testRenamedFile() throws Exception {
782+
createSvnRepository();
783+
752784
File reposRoot = new File(repositories.getSourceRoot(), "subversion");
753785
History updatedHistory;
754786

@@ -835,7 +867,7 @@ private void checkNoHistoryFetchRepo(String reponame, String filename,
835867
*/
836868
@EnabledForRepository({MERCURIAL, SCCS})
837869
@Test
838-
public void testNoHistoryFetch() throws Exception {
870+
void testNoHistoryFetch() throws Exception {
839871
// Do not create history cache for files which do not have it cached.
840872
env.setFetchHistoryWhenNotInCache(false);
841873

@@ -860,7 +892,7 @@ public void testNoHistoryFetch() throws Exception {
860892
@EnabledOnOs({OS.LINUX, OS.MAC, OS.SOLARIS, OS.AIX, OS.OTHER})
861893
@EnabledForRepository(MERCURIAL)
862894
@Test
863-
public void testStoreAndTryToGetIgnored() throws Exception {
895+
void testStoreAndTryToGetIgnored() throws Exception {
864896
env.getIgnoredNames().add("f:Make*");
865897

866898
File reposRoot = new File(repositories.getSourceRoot(), "mercurial");

0 commit comments

Comments
 (0)