From a7a10f357a771eb493c98adee21633fe609dfe89 Mon Sep 17 00:00:00 2001 From: Joseph Crail Date: Sun, 22 May 2016 15:29:23 -0400 Subject: [PATCH] tests: remove scoped files Scoped files were deprecated by scoped temporary directories used by the test harness. --- tests/common/util.rs | 39 --------------------------------------- tests/test_tail.rs | 12 ++++++------ 2 files changed, 6 insertions(+), 45 deletions(-) diff --git a/tests/common/util.rs b/tests/common/util.rs index 7fe99dda3..c0a28a0ea 100755 --- a/tests/common/util.rs +++ b/tests/common/util.rs @@ -3,7 +3,6 @@ use std::env; use std::fs::{self, File, OpenOptions}; use std::io::{Read, Write, Result}; -use std::ops::{Deref, DerefMut}; #[cfg(unix)] use std::os::unix::fs::symlink as symlink_file; #[cfg(windows)] @@ -120,40 +119,6 @@ pub fn get_root_path() -> &'static str { } } -/// A scoped, temporary file that is removed upon drop. -pub struct ScopedFile { - path: PathBuf, - file: File, -} - -impl ScopedFile { - fn new(path: PathBuf, file: File) -> ScopedFile { - ScopedFile { - path: path, - file: file - } - } -} - -impl Deref for ScopedFile { - type Target = File; - fn deref(&self) -> &File { - &self.file - } -} - -impl DerefMut for ScopedFile { - fn deref_mut(&mut self) -> &mut File { - &mut self.file - } -} - -impl Drop for ScopedFile { - fn drop(&mut self) { - fs::remove_file(&self.path).unwrap(); - } -} - pub struct AtPath { pub subdir: PathBuf, } @@ -234,10 +199,6 @@ impl AtPath { } } - pub fn make_scoped_file(&self, name: &str) -> ScopedFile { - ScopedFile::new(self.plus(name), self.make_file(name)) - } - pub fn touch(&self, file: &str) { log_info("touch", self.plus_as_string(file)); File::create(&self.plus(file)).unwrap(); diff --git a/tests/test_tail.rs b/tests/test_tail.rs index b3d211e2b..fbd527b39 100644 --- a/tests/test_tail.rs +++ b/tests/test_tail.rs @@ -65,13 +65,13 @@ fn test_single_big_args() { let (at, mut ucmd) = testing(UTIL_NAME); - let mut big_input = at.make_scoped_file(FILE); + let mut big_input = at.make_file(FILE); for i in 0..LINES { write!(&mut big_input, "Line {}\n", i).expect("Could not write to FILE"); } big_input.flush().expect("Could not flush FILE"); - let mut big_expected = at.make_scoped_file(EXPECTED_FILE); + let mut big_expected = at.make_file(EXPECTED_FILE); for i in (LINES - N_ARG)..LINES { write!(&mut big_expected, "Line {}\n", i).expect("Could not write to EXPECTED_FILE"); } @@ -104,14 +104,14 @@ fn test_bytes_big() { let (at, mut ucmd) = testing(UTIL_NAME); - let mut big_input = at.make_scoped_file(FILE); + let mut big_input = at.make_file(FILE); for i in 0..BYTES { let digit = from_digit((i % 10) as u32, 10).unwrap(); write!(&mut big_input, "{}", digit).expect("Could not write to FILE"); } big_input.flush().expect("Could not flush FILE"); - let mut big_expected = at.make_scoped_file(EXPECTED_FILE); + let mut big_expected = at.make_file(EXPECTED_FILE); for i in (BYTES - N_ARG)..BYTES { let digit = from_digit((i % 10) as u32, 10).unwrap(); write!(&mut big_expected, "{}", digit).expect("Could not write to EXPECTED_FILE"); @@ -171,13 +171,13 @@ fn test_lines_with_size_suffix() { let (at, mut ucmd) = testing(UTIL_NAME); - let mut big_input = at.make_scoped_file(FILE); + let mut big_input = at.make_file(FILE); for i in 0..LINES { writeln!(&mut big_input, "Line {}", i).expect("Could not write to FILE"); } big_input.flush().expect("Could not flush FILE"); - let mut big_expected = at.make_scoped_file(EXPECTED_FILE); + let mut big_expected = at.make_file(EXPECTED_FILE); for i in (LINES - N_ARG)..LINES { writeln!(&mut big_expected, "Line {}", i).expect("Could not write to EXPECTED_FILE"); }