[FIXED JENKINS-9540] Failure of recursive copy on slave side should be reported.

Instead it was being thrown in a Future that the master did not wait for:
the writing side failed with a closed pipe exception, and this meaningless error was thrown up.
Fixing by waiting for the reading side first, so any error there will be thrown up.
(If there was _also_ an error on the writing side, we would miss it, but typically this will just be the closed stream.)
This commit is contained in:
Jesse Glick committed 2013-08-29 16:13:48 -04:00
1 parent d75c350c7b
commit 574fe1409e
3 files changed
+51 -2

No files matched your search

@@ -206,6 +206,46 @@ public class FilePathTest extends ChannelTestCase {
}
}
@Bug(9540)
public void testErrorMessageInRemoteCopyRecursive() throws Exception {
File tmp = Util.createTempDir();
try {
File src = new File(tmp, "src");
File dst = new File(tmp, "dst");
FilePath from = new FilePath(src);
FilePath to = new FilePath(british, dst.getAbsolutePath());
for (int i = 0; i < 10000; i++) {
// TODO is there a simpler way to force the TarOutputStream to be flushed and the reader to start?
// Have not found a way to make the failure guaranteed.
OutputStream os = from.child("content" + i).write();
try {
for (int j = 0; j < 1024; j++) {
os.write('.');
}
} finally {
os.close();
}
}
FilePath toF = to.child("content0");
toF.write().close();
toF.chmod(0400);
try {
from.copyRecursiveTo(to);
// on Windows this may just succeed; OK, test did not prove anything then
} catch (IOException x) {
if (Functions.printThrowable(x).contains("content0")) {
// Fine, error message talks about permission denied.
} else {
throw x;
}
} finally {
toF.chmod(700);
}
} finally {
Util.deleteRecursive(tmp);
}
}
public void testArchiveBug4039() throws Exception {
File tmp = Util.createTempDir();
try {