Skip to content

Commit 540d860

Browse files
authored
Merge pull request #75 from jglick/empty-stash-JENKINS-52361
[JENKINS-52361] Verify behavior of empty stashes
2 parents 03b54d3 + bb1f9f9 commit 540d860

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/test/java/org/jenkinsci/plugins/workflow/ArtifactManagerTest.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,17 +255,26 @@ public void apply(DumbSlave agent, FreeStyleProject p, FreeStyleBuild b, FilePat
255255
env.putAll(agent.toComputer().buildEnvironment(listener));
256256
// Make sure we can stash and then unstash within a build:
257257
StashManager.stash(b, "stuff", ws, launcher, env, listener, "file", null, false, false);
258+
StashManager.stash(b, "empty", ws, launcher, env, listener, "nada", null, false, true);
259+
try {
260+
StashManager.stash(b, "empty", ws, launcher, env, listener, "nada", null, false, false);
261+
} catch (AbortException x) {
262+
System.err.println("good, allowEmpty is being enforced: " + x.getMessage());
263+
}
258264
ws.child("file").delete();
259265
StashManager.unstash(b, "stuff", ws, launcher, env, listener);
260266
assertEquals("content", ws.child("file").readToString());
261267
ws.child("file").delete();
268+
// Should have an empty stash somewhere:
269+
StashManager.unstash(b, "empty", ws, launcher, env, listener);
262270
// Copy stashes and artifacts from one build to a second one:
263271
p.getPublishersList().clear();
264272
FreeStyleBuild b2 = r.buildAndAssertSuccess(p);
265273
ExtensionList.lookupSingleton(StashManager.CopyStashesAndArtifacts.class).copy(b, b2, listener);
266274
// Verify the copied stashes:
267275
StashManager.unstash(b2, "stuff", ws, launcher, env, listener);
268276
assertEquals("content", ws.child("file").readToString());
277+
StashManager.unstash(b2, "empty", ws, launcher, env, listener);
269278
// And the copied artifacts:
270279
VirtualFile root = b2.getArtifactManager().root();
271280
new Verify(agent, root, weirdCharacters).run();

0 commit comments

Comments
 (0)