tests: remove scoped files

Scoped files were deprecated by scoped temporary directories used by the
test harness.
This commit is contained in:
Joseph Crail 2016-05-22 15:29:23 -04:00
parent 8d42cecc5f
commit a7a10f357a
2 changed files with 6 additions and 45 deletions

View file

@ -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();

View file

@ -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");
}