mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-30 04:27:45 +00:00
Move common methods into test library.
This commit is contained in:
parent
c3802bb69c
commit
4aed2eafa8
2 changed files with 17 additions and 12 deletions
|
@ -1,5 +1,6 @@
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
|
|
||||||
|
use std::env;
|
||||||
use std::fs::{self, File};
|
use std::fs::{self, File};
|
||||||
use std::io::{Read, Write};
|
use std::io::{Read, Write};
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
|
@ -93,3 +94,15 @@ pub fn cleanup(path: &'static str) {
|
||||||
Err(_) => {}
|
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
|
||||||
|
}
|
||||||
|
|
|
@ -1,21 +1,13 @@
|
||||||
use std::env;
|
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
use std::str;
|
use std::str;
|
||||||
|
use util::*;
|
||||||
|
|
||||||
static PROGNAME: &'static str = "./readlink";
|
static PROGNAME: &'static str = "./readlink";
|
||||||
static GIBBERISH: &'static str = "supercalifragilisticexpialidocious";
|
static GIBBERISH: &'static str = "supercalifragilisticexpialidocious";
|
||||||
|
|
||||||
fn current_directory() -> String {
|
#[path = "common/util.rs"]
|
||||||
env::current_dir().unwrap().into_os_string().into_string().unwrap()
|
#[macro_use]
|
||||||
}
|
mod util;
|
||||||
|
|
||||||
fn repeat_str(s: &str, n: u32) -> String {
|
|
||||||
let mut repeated = String::new();
|
|
||||||
for _ in 0 .. n {
|
|
||||||
repeated.push_str(s);
|
|
||||||
}
|
|
||||||
repeated
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_canonicalize() {
|
fn test_canonicalize() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue