Skip to content

Commit a6ecc86

Browse files
authored
Cleanup test_remove. NFC (#23081)
- Convert to C. - Move to `test/stdio` This test was originally added in c008b11 and is not specific to C++ cstdio and was the only file in this directory. Also remove the cleanup code. See #23003.
1 parent 78c968b commit a6ecc86

File tree

3 files changed

+9
-19
lines changed

3 files changed

+9
-19
lines changed

test/cstdio/test_remove.cpp renamed to test/stdio/test_remove.c

+8-18
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55

66
#include <assert.h>
77
#include <errno.h>
8-
#include <cstdio>
9-
#include <iostream>
8+
#include <stdio.h>
109
#include <string.h>
1110
#include <unistd.h>
1211
#include <stdlib.h>
@@ -30,38 +29,29 @@ void setup() {
3029
mkdir("dir/subdir", 0777);
3130
}
3231

33-
void cleanup() {
34-
// make sure we get it all regardless of anything failing
35-
unlink("file");
36-
unlink("dir/file");
37-
rmdir("dir/subdir");
38-
rmdir("dir");
39-
}
40-
4132
void test() {
4233
int err;
43-
44-
err = std::remove("dir/file");
34+
35+
err = remove("dir/file");
4536
assert(!err);
4637

47-
err = std::remove("file");
38+
err = remove("file");
4839
assert(!err);
4940

5041
// should fail, folder is not empty
51-
err = std::remove("dir");
42+
err = remove("dir");
5243
assert(err);
5344

54-
err = std::remove("dir/subdir");
45+
err = remove("dir/subdir");
5546
assert(!err);
5647

57-
err = std::remove("dir");
48+
err = remove("dir");
5849
assert(!err);
5950

60-
std::cout << "success\n";
51+
printf("success\n");
6152
}
6253

6354
int main() {
64-
atexit(cleanup);
6555
setup();
6656
test();
6757
return 0;
File renamed without changes.

test/test_core.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1697,7 +1697,7 @@ def test_rename(self):
16971697
self.do_run_in_out_file_test('stdio/test_rename.c')
16981698

16991699
def test_remove(self):
1700-
self.do_run_in_out_file_test('cstdio/test_remove.cpp')
1700+
self.do_run_in_out_file_test('stdio/test_remove.c')
17011701

17021702
def test_alloca_stack(self):
17031703
self.do_core_test('test_alloca_stack.c')

0 commit comments

Comments
 (0)