From cd9fa96733277247c283caa441cf54c14d646dca Mon Sep 17 00:00:00 2001 From: Michihiro NAKAJIMA Date: Fri, 18 Dec 2009 11:33:36 -0500 Subject: [PATCH] On Windows, make sure not to leave empty directories when tests are success. SVN-Revision: 1761 --- cpio/test/main.c | 14 +++++++++++++- libarchive/test/main.c | 14 +++++++++++++- tar/test/main.c | 14 +++++++++++++- 3 files changed, 39 insertions(+), 3 deletions(-) diff --git a/cpio/test/main.c b/cpio/test/main.c index c37c0746e..f40f38db0 100644 --- a/cpio/test/main.c +++ b/cpio/test/main.c @@ -1707,7 +1707,19 @@ test_run(int i, const char *tmpdir) if (tests[i].failures == 0) { if (!keep_temp_files && assertChdir(tmpdir)) { #if defined(_WIN32) && !defined(__CYGWIN__) - systemf("rmdir /S /Q %s", tests[i].name); + /* Make sure not to leave empty directories. + * Sometimes a processing of closing files used by tests + * is not done, then rmdir will be failed and it will + * leave a empty test directory. So we should wait a few + * seconds and retry rmdir. */ + int r, t; + for (t = 0; t < 10; t++) { + if (t > 0) + Sleep(1000); + r = systemf("rmdir /S /Q %s", tests[i].name); + if (r == 0) + break; + } systemf("del %s", logfilename); #else systemf("rm -rf %s", tests[i].name); diff --git a/libarchive/test/main.c b/libarchive/test/main.c index b35cc2349..0c4e2f774 100644 --- a/libarchive/test/main.c +++ b/libarchive/test/main.c @@ -1703,7 +1703,19 @@ test_run(int i, const char *tmpdir) if (tests[i].failures == 0) { if (!keep_temp_files && assertChdir(tmpdir)) { #if defined(_WIN32) && !defined(__CYGWIN__) - systemf("rmdir /S /Q %s", tests[i].name); + /* Make sure not to leave empty directories. + * Sometimes a processing of closing files used by tests + * is not done, then rmdir will be failed and it will + * leave a empty test directory. So we should wait a few + * seconds and retry rmdir. */ + int r, t; + for (t = 0; t < 10; t++) { + if (t > 0) + Sleep(1000); + r = systemf("rmdir /S /Q %s", tests[i].name); + if (r == 0) + break; + } systemf("del %s", logfilename); #else systemf("rm -rf %s", tests[i].name); diff --git a/tar/test/main.c b/tar/test/main.c index 19391eb97..cbf453c56 100644 --- a/tar/test/main.c +++ b/tar/test/main.c @@ -1708,7 +1708,19 @@ test_run(int i, const char *tmpdir) if (tests[i].failures == 0) { if (!keep_temp_files && assertChdir(tmpdir)) { #if defined(_WIN32) && !defined(__CYGWIN__) - systemf("rmdir /S /Q %s", tests[i].name); + /* Make sure not to leave empty directories. + * Sometimes a processing of closing files used by tests + * is not done, then rmdir will be failed and it will + * leave a empty test directory. So we should wait a few + * seconds and retry rmdir. */ + int r, t; + for (t = 0; t < 10; t++) { + if (t > 0) + Sleep(1000); + r = systemf("rmdir /S /Q %s", tests[i].name); + if (r == 0) + break; + } systemf("del %s", logfilename); #else systemf("rm -rf %s", tests[i].name); -- 2.47.3