Skip to content

Commit a0c21f4

Browse files
committed
Avoid double unlink in tests
1 parent 1fbdb90 commit a0c21f4

25 files changed

Lines changed: 57 additions & 55 deletions

‎tests/lit/lit/formats/Cpp2RustTest.py‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,14 +261,18 @@ def build_rust(self):
261261
def run_cpp(self):
262262
if self.skip_run:
263263
return None
264-
self.cpp_result = RunResult(*lit.util.executeCommand(str(self.cpp_bin)))
264+
self.cpp_result = RunResult(
265+
*lit.util.executeCommand(str(self.cpp_bin), str(self.tmp_dir))
266+
)
265267
return None
266268

267269
def run_rust(self):
268270
exp = self.expectations
269271
if self.skip_run:
270272
return None
271-
self.rust_result = RunResult(*lit.util.executeCommand(str(self.rust_bin)))
273+
self.rust_result = RunResult(
274+
*lit.util.executeCommand(str(self.rust_bin), str(self.tmp_dir))
275+
)
272276

273277
if exp.should_panic_ub:
274278
err = str(self.rust_result.stderr)

‎tests/unit/fd_io.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include <unistd.h>
55

66
int main(void) {
7-
const char *path = "/tmp/cpp2rust_fd_io_test.tmp";
7+
const char *path = "cpp2rust_fd_io_test.tmp";
88
int fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0644);
99
assert(fd >= 0);
1010
assert(write(fd, "hello world", 11) == 11);

‎tests/unit/fstat.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include <unistd.h>
55

66
int main(void) {
7-
const char *path = "/tmp/cpp2rust_fstat_test.tmp";
7+
const char *path = "cpp2rust_fstat_test.tmp";
88
int fd = open(path, O_RDWR | O_CREAT | O_TRUNC, 0644);
99
assert(fd >= 0);
1010
assert(write(fd, "hello", 5) == 5);

‎tests/unit/isatty.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include <unistd.h>
44

55
int main(void) {
6-
const char *path = "/tmp/cpp2rust_isatty_test.tmp";
6+
const char *path = "cpp2rust_isatty_test.tmp";
77
int fd = open(path, O_RDWR | O_CREAT | O_TRUNC, 0644);
88
assert(fd >= 0);
99
assert(isatty(fd) == 0);

‎tests/unit/lseek_ftruncate.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include <unistd.h>
55

66
int main(void) {
7-
const char *path = "/tmp/cpp2rust_lseek_ftruncate_test.tmp";
7+
const char *path = "cpp2rust_lseek_ftruncate_test.tmp";
88
int fd = open(path, O_RDWR | O_CREAT | O_TRUNC, 0644);
99
assert(fd >= 0);
1010
assert(write(fd, "hello world", 11) == 11);

‎tests/unit/out/refcount/fd_io.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub fn main() {
1111
}
1212
fn main_0() -> i32 {
1313
let path: Value<Ptr<u8>> = Rc::new(RefCell::new(Ptr::from_string_literal(
14-
b"/tmp/cpp2rust_fd_io_test.tmp",
14+
b"cpp2rust_fd_io_test.tmp",
1515
)));
1616
let fd: Value<i32> = Rc::new(RefCell::new({
1717
let __mode = match &[(420).into()].first() {

‎tests/unit/out/refcount/fstat.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub fn main() {
1111
}
1212
fn main_0() -> i32 {
1313
let path: Value<Ptr<u8>> = Rc::new(RefCell::new(Ptr::from_string_literal(
14-
b"/tmp/cpp2rust_fstat_test.tmp",
14+
b"cpp2rust_fstat_test.tmp",
1515
)));
1616
let fd: Value<i32> = Rc::new(RefCell::new({
1717
let __mode = match &[(420).into()].first() {

‎tests/unit/out/refcount/isatty.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub fn main() {
1111
}
1212
fn main_0() -> i32 {
1313
let path: Value<Ptr<u8>> = Rc::new(RefCell::new(Ptr::from_string_literal(
14-
b"/tmp/cpp2rust_isatty_test.tmp",
14+
b"cpp2rust_isatty_test.tmp",
1515
)));
1616
let fd: Value<i32> = Rc::new(RefCell::new({
1717
let __mode = match &[(420).into()].first() {

‎tests/unit/out/refcount/lseek_ftruncate.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub fn main() {
1111
}
1212
fn main_0() -> i32 {
1313
let path: Value<Ptr<u8>> = Rc::new(RefCell::new(Ptr::from_string_literal(
14-
b"/tmp/cpp2rust_lseek_ftruncate_test.tmp",
14+
b"cpp2rust_lseek_ftruncate_test.tmp",
1515
)));
1616
let fd: Value<i32> = Rc::new(RefCell::new({
1717
let __mode = match &[(420).into()].first() {

‎tests/unit/out/refcount/stdio_nofd.rs‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::os::fd::AsFd;
88
use std::rc::{Rc, Weak};
99
pub fn test_fputc_fputs_0() {
1010
let path: Value<Ptr<u8>> = Rc::new(RefCell::new(Ptr::from_string_literal(
11-
b"/tmp/cpp2rust_stdio_nofd_puts.tmp",
11+
b"cpp2rust_stdio_nofd_puts.tmp",
1212
)));
1313
let fp: Value<Ptr<::std::fs::File>> = Rc::new(RefCell::new(
1414
match Ptr::from_string_literal(b"wb").to_rust_string() {
@@ -154,7 +154,7 @@ pub fn test_puts_1() {
154154
}
155155
pub fn test_fgets_getc_2() {
156156
let path: Value<Ptr<u8>> = Rc::new(RefCell::new(Ptr::from_string_literal(
157-
b"/tmp/cpp2rust_stdio_nofd_gets.tmp",
157+
b"cpp2rust_stdio_nofd_gets.tmp",
158158
)));
159159
let fp: Value<Ptr<::std::fs::File>> = Rc::new(RefCell::new(
160160
match Ptr::from_string_literal(b"wb").to_rust_string() {
@@ -464,7 +464,7 @@ pub fn test_fgets_getc_2() {
464464
}
465465
pub fn test_freopen_3() {
466466
let path: Value<Ptr<u8>> = Rc::new(RefCell::new(Ptr::from_string_literal(
467-
b"/tmp/cpp2rust_stdio_nofd_reopen.tmp",
467+
b"cpp2rust_stdio_nofd_reopen.tmp",
468468
)));
469469
let fp: Value<Ptr<::std::fs::File>> = Rc::new(RefCell::new(
470470
match Ptr::from_string_literal(b"wb").to_rust_string() {
@@ -571,7 +571,7 @@ pub fn test_freopen_3() {
571571
}
572572
pub fn test_fseeko_4() {
573573
let path: Value<Ptr<u8>> = Rc::new(RefCell::new(Ptr::from_string_literal(
574-
b"/tmp/cpp2rust_stdio_nofd_seek.tmp",
574+
b"cpp2rust_stdio_nofd_seek.tmp",
575575
)));
576576
let fp: Value<Ptr<::std::fs::File>> = Rc::new(RefCell::new(
577577
match Ptr::from_string_literal(b"wb").to_rust_string() {
@@ -758,10 +758,10 @@ pub fn test_fseeko_4() {
758758
}
759759
pub fn test_rename_5() {
760760
let from: Value<Ptr<u8>> = Rc::new(RefCell::new(Ptr::from_string_literal(
761-
b"/tmp/cpp2rust_stdio_nofd_from.tmp",
761+
b"cpp2rust_stdio_nofd_from.tmp",
762762
)));
763763
let to: Value<Ptr<u8>> = Rc::new(RefCell::new(Ptr::from_string_literal(
764-
b"/tmp/cpp2rust_stdio_nofd_to.tmp",
764+
b"cpp2rust_stdio_nofd_to.tmp",
765765
)));
766766
let fp: Value<Ptr<::std::fs::File>> = Rc::new(RefCell::new(
767767
match Ptr::from_string_literal(b"wb").to_rust_string() {
@@ -884,7 +884,7 @@ pub fn test_rename_5() {
884884
}
885885
pub fn test_setvbuf_6() {
886886
let path: Value<Ptr<u8>> = Rc::new(RefCell::new(Ptr::from_string_literal(
887-
b"/tmp/cpp2rust_stdio_nofd_vbuf.tmp",
887+
b"cpp2rust_stdio_nofd_vbuf.tmp",
888888
)));
889889
let fp: Value<Ptr<::std::fs::File>> = Rc::new(RefCell::new(
890890
match Ptr::from_string_literal(b"wb").to_rust_string() {

0 commit comments

Comments
 (0)