From 4aed2eafa8d36c431270c9493fa4618ed8d76311 Mon Sep 17 00:00:00 2001 From: Joseph Crail Date: Thu, 4 Jun 2015 00:04:10 -0400 Subject: [PATCH] Move common methods into test library. --- test/common/util.rs | 13 +++++++++++++ test/readlink.rs | 16 ++++------------ 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/test/common/util.rs b/test/common/util.rs index 75a609b5c..f8db8a8a8 100644 --- a/test/common/util.rs +++ b/test/common/util.rs @@ -1,5 +1,6 @@ #![allow(dead_code)] +use std::env; use std::fs::{self, File}; use std::io::{Read, Write}; #[cfg(unix)] @@ -93,3 +94,15 @@ pub fn cleanup(path: &'static str) { Err(_) => {} } } + +pub fn current_directory() -> String { + env::current_dir().unwrap().into_os_string().into_string().unwrap() +} + +pub fn repeat_str(s: &str, n: u32) -> String { + let mut repeated = String::new(); + for _ in 0 .. n { + repeated.push_str(s); + } + repeated +} diff --git a/test/readlink.rs b/test/readlink.rs index 3e495cbec..6471d1d92 100644 --- a/test/readlink.rs +++ b/test/readlink.rs @@ -1,21 +1,13 @@ -use std::env; use std::process::Command; use std::str; +use util::*; static PROGNAME: &'static str = "./readlink"; static GIBBERISH: &'static str = "supercalifragilisticexpialidocious"; -fn current_directory() -> String { - env::current_dir().unwrap().into_os_string().into_string().unwrap() -} - -fn repeat_str(s: &str, n: u32) -> String { - let mut repeated = String::new(); - for _ in 0 .. n { - repeated.push_str(s); - } - repeated -} +#[path = "common/util.rs"] +#[macro_use] +mod util; #[test] fn test_canonicalize() {