Skip to content

Commit d2c3704

Browse files
authored
Merge pull request #690 from MarkEWaite/fix-centos-6-test-failures
Fix CentOS 6 test failures
2 parents 3c8f1d7 + f925711 commit d2c3704

File tree

5 files changed

+14
-173
lines changed

5 files changed

+14
-173
lines changed

pom.xml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -139,16 +139,6 @@
139139
<artifactId>mockito-core</artifactId>
140140
<scope>test</scope>
141141
</dependency>
142-
<dependency>
143-
<groupId>org.powermock</groupId>
144-
<artifactId>powermock-module-junit4</artifactId>
145-
<scope>test</scope>
146-
</dependency>
147-
<dependency>
148-
<groupId>org.powermock</groupId>
149-
<artifactId>powermock-api-mockito2</artifactId>
150-
<scope>test</scope>
151-
</dependency>
152142
<dependency>
153143
<groupId>nl.jqno.equalsverifier</groupId>
154144
<artifactId>equalsverifier</artifactId>

src/test/java/hudson/plugins/git/GitChangeSetPluginHistoryTest.java

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,13 @@
2525
import static org.hamcrest.CoreMatchers.is;
2626
import static org.hamcrest.Matchers.*;
2727
import static org.junit.Assert.*;
28+
import org.junit.ClassRule;
2829
import org.junit.Test;
2930
import org.junit.runner.RunWith;
3031
import org.junit.runners.Parameterized;
3132

33+
import jenkins.plugins.git.GitSampleRepoRule;
34+
3235
@RunWith(Parameterized.class)
3336
public class GitChangeSetPluginHistoryTest {
3437

@@ -41,19 +44,25 @@ public class GitChangeSetPluginHistoryTest {
4144

4245
private final GitChangeSet changeSet;
4346

44-
private static String gitVersion = "Unknown";
47+
@ClassRule
48+
public static GitSampleRepoRule sampleRepo = new GitSampleRepoRule();
4549

4650
/* git 1.7.1 on CentOS 6.7 "whatchanged" generates no output for
4751
* the SHA1 hashes (from this repository) in this list. Rather
4852
* than skip testing on that old git version, this exclusion list
4953
* allows most tests to run. Debian 6 / git 1.7.2.5 also has the issue.
5054
*/
5155
private static final String[] git171exceptions = {
56+
"6e467b23",
5257
"750b6806",
5358
"7eeb070b",
5459
"87988f4d",
60+
"94d982c2",
5561
"a571899e",
56-
"bc71cd2d"
62+
"b9e497b0",
63+
"bc71cd2d",
64+
"dcd329f4",
65+
"edf066f3",
5766
};
5867

5968
public GitChangeSetPluginHistoryTest(GitClient git, boolean authorOrCommitter, String sha1String) throws IOException, InterruptedException {
@@ -66,20 +75,6 @@ public GitChangeSetPluginHistoryTest(GitClient git, boolean authorOrCommitter, S
6675
changeSet = new GitChangeSet(changeLogStrings, authorOrCommitter);
6776
}
6877

69-
private static String getGitVersion() throws IOException {
70-
Process process = new ProcessBuilder("git", "--version").start();
71-
String version;
72-
try (BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()))) {
73-
version = "unknown";
74-
String line;
75-
while ((line = reader.readLine()) != null) {
76-
version = line.trim();
77-
}
78-
}
79-
process.destroy();
80-
return version;
81-
}
82-
8378
/**
8479
* Merge changes won't compute their date in GitChangeSet, apparently as an
8580
* intentional design choice. Return all changes for this repository which
@@ -116,8 +111,6 @@ private static List<ObjectId> getNonMergeChanges(boolean honorExclusions) throws
116111

117112
@Parameterized.Parameters(name = "{2}-{1}")
118113
public static Collection<Object[]> generateData() throws IOException, InterruptedException {
119-
gitVersion = getGitVersion();
120-
121114
List<Object[]> args = new ArrayList<>();
122115
String[] implementations = new String[]{"git", "jgit"};
123116
boolean[] choices = {true, false};
@@ -126,8 +119,7 @@ public static Collection<Object[]> generateData() throws IOException, Interrupte
126119
EnvVars envVars = new EnvVars();
127120
TaskListener listener = StreamTaskListener.fromStdout();
128121
GitClient git = Git.with(listener, envVars).in(new FilePath(new File("."))).using(implementation).getClient();
129-
boolean honorExclusions = implementation.equals("git")
130-
&& (gitVersion.equals("git version 1.7.1") || gitVersion.equals("git version 1.7.2.5"));
122+
boolean honorExclusions = implementation.equals("git") && !sampleRepo.gitVersionAtLeast(1, 7, 10);
131123
List<ObjectId> allNonMergeChanges = getNonMergeChanges(honorExclusions);
132124
int count = allNonMergeChanges.size() / 10; /* 10% of all changes */
133125

src/test/java/jenkins/plugins/git/AbstractGitSCMSourceRetrieveHeadsTest.java

Lines changed: 0 additions & 140 deletions
This file was deleted.

src/test/java/jenkins/plugins/git/GitSCMTelescopeTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
import java.util.Iterator;
5353
import java.util.List;
5454
import java.util.Set;
55-
import static jenkins.plugins.git.AbstractGitSCMSourceRetrieveHeadsTest.EXPECTED_GIT_EXE;
5655
import jenkins.plugins.git.traits.GitBrowserSCMSourceTrait;
5756
import jenkins.plugins.git.traits.GitToolSCMSourceTrait;
5857
import jenkins.scm.api.SCMFileSystem;
@@ -555,7 +554,7 @@ public AbstractGitSCMSourceImpl() {
555554
@NonNull
556555
@Override
557556
public List<SCMSourceTrait> getTraits() {
558-
return Collections.<SCMSourceTrait>singletonList(new GitToolSCMSourceTrait(EXPECTED_GIT_EXE) {
557+
return Collections.<SCMSourceTrait>singletonList(new GitToolSCMSourceTrait("git-custom") {
559558
@Override
560559
public SCMSourceTraitDescriptor getDescriptor() {
561560
return new GitBrowserSCMSourceTrait.DescriptorImpl();

src/test/java/jenkins/plugins/git/GitSampleRepoRule.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public boolean gitVersionAtLeast(int neededMajor, int neededMinor, int neededPat
114114
if (gitMajor < 1 || gitMajor > 3) {
115115
System.out.println("WARNING: Unexpected git major version " + gitMajor + " parsed from '" + versionOutput + "', field:'" + fields[0] + "'");
116116
}
117-
if (gitMinor < 0 || gitMinor > 20) {
117+
if (gitMinor < 0 || gitMinor > 50) {
118118
System.out.println("WARNING: Unexpected git minor version " + gitMinor + " parsed from '" + versionOutput + "', field:'" + fields[1] + "'");
119119
}
120120
if (gitPatch < 0 || gitPatch > 20) {

0 commit comments

Comments
 (0)