Skip to content

Commit

Permalink
Remove outdated test conditionals (#1594)
Browse files Browse the repository at this point in the history
Git plugin is no longer tested or supported on operating systems with
a command line git version older than 2.20 (Debian 10).  This removes
outdated tests.  It does not prevent the plugin from running with
older versions, but removes test clutter from older versions.
  • Loading branch information
MarkEWaite committed Jun 15, 2024
1 parent 63042e1 commit 49a51af
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 31 deletions.
35 changes: 5 additions & 30 deletions src/test/java/hudson/plugins/git/GitHooksTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,6 @@ public void testPipelineFromScm() throws Exception {
GitHooksConfiguration.get().setAllowedOnAgents(false);
run = r.buildAndAssertSuccess(job);
r.assertLogContains("Hello Pipeline", run);
if (!sampleRepo.gitVersionAtLeast(2, 0)) {
// Git 1.8 does not output hook text in this case
// Not important enough to research the difference
return;
}
assertFalse(postCheckoutOutput1.exists());
assertFalse(postCheckoutOutput2.exists());

Expand Down Expand Up @@ -213,20 +208,12 @@ public void testPipelineCheckoutController() throws Exception {
commit("Commit3", janeDoe, "Commit number 3");
GitHooksConfiguration.get().setAllowedOnController(true);
run = r.buildAndAssertSuccess(job);
if (sampleRepo.gitVersionAtLeast(2, 0)) {
// Git 1.8 does not output hook text in this case
// Not important enough to research the difference
r.assertLogContains("h4xor3d", run);
}
r.assertLogContains("h4xor3d", run);
GitHooksConfiguration.get().setAllowedOnController(false);
GitHooksConfiguration.get().setAllowedOnAgents(true);
commit("Commit4", janeDoe, "Commit number 4");
run = r.buildAndAssertSuccess(job);
if (sampleRepo.gitVersionAtLeast(2, 0)) {
// Git 1.8 does not output hook text in this case
// Not important enough to research the difference
r.assertLogNotContains("h4xor3d", run);
}
r.assertLogNotContains("h4xor3d", run);
}

@Test
Expand All @@ -245,20 +232,12 @@ public void testPipelineCheckoutAgent() throws Exception {
commit("Commit3", janeDoe, "Commit number 3");
GitHooksConfiguration.get().setAllowedOnAgents(true);
run = r.buildAndAssertSuccess(job);
if (sampleRepo.gitVersionAtLeast(2, 0)) {
// Git 1.8 does not output hook text in this case
// Not important enough to research the difference
r.assertLogContains("h4xor3d", run);
}
r.assertLogContains("h4xor3d", run);
GitHooksConfiguration.get().setAllowedOnAgents(false);
GitHooksConfiguration.get().setAllowedOnController(true);
commit("Commit4", janeDoe, "Commit number 4");
run = r.buildAndAssertSuccess(job);
if (sampleRepo.gitVersionAtLeast(2, 0)) {
// Git 1.8 does not output hook text in this case
// Not important enough to research the difference
r.assertLogNotContains("h4xor3d", run);
}
r.assertLogNotContains("h4xor3d", run);
}

private WorkflowJob setupAndRunPipelineCheckout(String node) throws Exception {
Expand Down Expand Up @@ -289,11 +268,7 @@ private WorkflowJob setupAndRunPipelineCheckout(String node) throws Exception {
final String commitFile2 = "commitFile2";
commit(commitFile2, janeDoe, "Commit number 2");
run = r.buildAndAssertSuccess(job);
if (sampleRepo.gitVersionAtLeast(2, 0)) {
// Git 1.8 does not output hook text in this case
// Not important enough to research the difference
r.assertLogNotContains("h4xor3d", run);
}
r.assertLogNotContains("h4xor3d", run);
return job;
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/java/jenkins/plugins/git/GitSampleRepoRule.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public void init() throws Exception {
git("init", "--template="); // initialize without copying the installation defaults to ensure a vanilla repo that behaves the same everywhere
if (gitVersionAtLeast(2, 30)) {
// Force branch name to master even if system default is not master
// Fails on git 2.25, 2.20, 2.17, and 1.8
// Fails on git 2.25, 2.20, and 2.17
// Works on git 2.30 and later
git("branch", "-m", "master");
}
Expand Down

0 comments on commit 49a51af

Please sign in to comment.