Skip to content

Commit

Permalink
Fix cordtst2.tmp file deletion in cordtest on Windows
Browse files Browse the repository at this point in the history
On Windows, remove() operation deletes the file only if the file is
closed.

* cord/tests/cordtest.c (test_extras): Do not call remove(FNAME2).
* cord/tests/cordtest.c (main): Call GC_gcollect() and remove(FNAME2)
just before printing the test succeeded; add comment.
  • Loading branch information
ivmai committed May 2, 2024
1 parent cbef414 commit 9bea6a1
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions cord/tests/cordtest.c
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,6 @@ static void test_extras(void)
/* But we cannot call fclose as it might lead to double close. */
fprintf(stderr, "WARNING: remove failed: " FNAME1 "\n");
}
if (remove(FNAME2) != 0) {
fprintf(stderr, "WARNING: remove failed: " FNAME2 "\n");
}
}

static int wrap_vprintf(CORD format, ...)
Expand Down Expand Up @@ -402,6 +399,11 @@ int main(void)
test_basics();
test_extras();
test_printf();

GC_gcollect(); /* to close f2 before the file removal */
if (remove(FNAME2) != 0) {
fprintf(stderr, "WARNING: remove failed: " FNAME2 "\n");
}
CORD_fprintf(stdout, "SUCCEEDED\n");
return 0;
}

0 comments on commit 9bea6a1

Please sign in to comment.