mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2026-01-20 20:21:09 +00:00
Merge pull request #885 from jbcrail/refactor-tests
Refactor and fix tests
This commit is contained in:
commit
145f2efe89
12 changed files with 101 additions and 122 deletions
|
|
@ -12,4 +12,8 @@ uucore = { path="../uucore" }
|
|||
getopts = "*"
|
||||
libc = "*"
|
||||
rand = "0.3"
|
||||
tempfile = {git = "https://github.com/Stebalien/tempfile.git"}
|
||||
tempfile = "*"
|
||||
|
||||
[[bin]]
|
||||
name = "mktemp"
|
||||
path = "main.rs"
|
||||
|
|
|
|||
5
src/mktemp/main.rs
Normal file
5
src/mktemp/main.rs
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
extern crate uu_mktemp;
|
||||
|
||||
fn main() {
|
||||
std::process::exit(uu_mktemp::uumain(std::env::args().collect()));
|
||||
}
|
||||
|
|
@ -31,7 +31,6 @@ static VERSION: &'static str = env!("CARGO_PKG_VERSION");
|
|||
static DEFAULT_TEMPLATE: &'static str = "tmp.XXXXXXXXXX";
|
||||
|
||||
|
||||
|
||||
pub fn uumain(args: Vec<String>) -> i32 {
|
||||
let mut opts = getopts::Options::new();
|
||||
opts.optflag("d", "directory", "Make a directory instead of a file");
|
||||
|
|
@ -171,16 +170,12 @@ pub fn dry_exec(mut tmpdir: PathBuf, prefix: &str, rand: usize, suffix: &str) ->
|
|||
0
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
fn exec(tmpdir: PathBuf, prefix: &str, rand: usize, suffix: &str, make_dir: bool) -> i32 {
|
||||
// TODO: respect make_dir option
|
||||
if make_dir {
|
||||
crash!(1, "Directory option is not supported yet. Sorry.");
|
||||
}
|
||||
|
||||
|
||||
let tmpfile = NamedTempFileOptions::new()
|
||||
.prefix(prefix)
|
||||
.rand_bytes(rand)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue