Move common methods into test library.

This commit is contained in:
Joseph Crail 2015-06-04 00:04:10 -04:00
parent c3802bb69c
commit 4aed2eafa8
2 changed files with 17 additions and 12 deletions

View file

@ -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
}

View file

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