2015-05-29 17:47:00 +00:00
|
|
|
use std::process::Command;
|
|
|
|
use util::*;
|
2014-01-04 04:33:05 +00:00
|
|
|
|
2015-05-13 20:38:11 +00:00
|
|
|
static PROGNAME: &'static str = "./mkdir";
|
2014-10-07 04:34:54 +00:00
|
|
|
static TEST_DIR1: &'static str = "mkdir_test1";
|
|
|
|
static TEST_DIR2: &'static str = "mkdir_test2";
|
|
|
|
static TEST_DIR3: &'static str = "mkdir_test3";
|
|
|
|
static TEST_DIR4: &'static str = "mkdir_test4/mkdir_test4_1";
|
|
|
|
static TEST_DIR5: &'static str = "mkdir_test5/mkdir_test5_1";
|
2014-01-04 04:33:05 +00:00
|
|
|
|
2015-05-29 17:47:00 +00:00
|
|
|
#[path = "common/util.rs"]
|
|
|
|
#[macro_use]
|
|
|
|
mod util;
|
2014-01-04 04:33:05 +00:00
|
|
|
|
2014-01-05 22:03:13 +00:00
|
|
|
#[test]
|
2014-01-04 04:33:05 +00:00
|
|
|
fn test_mkdir_mkdir() {
|
2015-05-29 17:47:00 +00:00
|
|
|
let mut cmd = Command::new(PROGNAME);
|
|
|
|
let exit_success = run(&mut cmd.arg(TEST_DIR1)).success;
|
2014-10-07 04:34:54 +00:00
|
|
|
cleanup(TEST_DIR1);
|
2014-01-04 04:33:05 +00:00
|
|
|
assert_eq!(exit_success, true);
|
|
|
|
}
|
|
|
|
|
2014-01-05 22:03:13 +00:00
|
|
|
#[test]
|
2014-01-04 04:33:05 +00:00
|
|
|
fn test_mkdir_dup_dir() {
|
2015-05-29 17:47:00 +00:00
|
|
|
let mut cmd = Command::new(PROGNAME);
|
|
|
|
let exit_success = run(&mut cmd.arg(TEST_DIR2)).success;
|
2014-01-04 04:33:05 +00:00
|
|
|
if !exit_success {
|
2014-10-07 04:34:54 +00:00
|
|
|
cleanup(TEST_DIR2);
|
2014-10-30 09:06:47 +00:00
|
|
|
panic!();
|
2014-01-04 04:33:05 +00:00
|
|
|
}
|
2015-05-29 17:47:00 +00:00
|
|
|
let exit_success2 = run(&mut cmd.arg(TEST_DIR2)).success;
|
2014-10-07 04:34:54 +00:00
|
|
|
cleanup(TEST_DIR2);
|
2014-01-04 04:33:05 +00:00
|
|
|
assert_eq!(exit_success2, false);
|
|
|
|
}
|
|
|
|
|
2014-01-05 22:03:13 +00:00
|
|
|
#[test]
|
2014-01-04 04:33:05 +00:00
|
|
|
fn test_mkdir_mode() {
|
2015-05-29 17:47:00 +00:00
|
|
|
let mut cmd = Command::new(PROGNAME);
|
|
|
|
let exit_success = run(&mut cmd.arg("-m").arg("755").arg(TEST_DIR3)).success;
|
2014-10-07 04:34:54 +00:00
|
|
|
cleanup(TEST_DIR3);
|
2014-01-04 04:33:05 +00:00
|
|
|
assert_eq!(exit_success, true);
|
|
|
|
}
|
|
|
|
|
2014-01-05 22:03:13 +00:00
|
|
|
#[test]
|
2014-01-04 04:33:05 +00:00
|
|
|
fn test_mkdir_parent() {
|
2015-05-29 17:47:00 +00:00
|
|
|
let mut cmd = Command::new(PROGNAME);
|
|
|
|
let exit_success = run(&mut cmd.arg("-p").arg(TEST_DIR4)).success;
|
2014-10-07 04:34:54 +00:00
|
|
|
cleanup(TEST_DIR4);
|
2014-01-04 04:33:05 +00:00
|
|
|
assert_eq!(exit_success, true);
|
|
|
|
}
|
|
|
|
|
2014-01-05 22:03:13 +00:00
|
|
|
#[test]
|
2014-01-04 04:33:05 +00:00
|
|
|
fn test_mkdir_no_parent() {
|
2015-05-29 17:47:00 +00:00
|
|
|
let mut cmd = Command::new(PROGNAME);
|
|
|
|
let exit_success = run(&mut cmd.arg(TEST_DIR5)).success;
|
2014-10-07 04:34:54 +00:00
|
|
|
cleanup(TEST_DIR5);
|
2014-01-04 04:33:05 +00:00
|
|
|
assert_eq!(exit_success, false);
|
2014-01-03 23:32:39 +00:00
|
|
|
}
|