Adding tests for ls. Corrected issue with ls on the present directory throwing panic!()

This commit is contained in:
Jeremiah Peschka 2016-03-25 14:25:52 -07:00
parent 825a850fa9
commit 0bb0c40c36
4 changed files with 38 additions and 2 deletions

20
Cargo.lock generated
View file

@ -35,6 +35,7 @@ dependencies = [
"link 0.0.1",
"ln 0.0.1",
"logname 0.0.1",
"ls 0.0.1",
"memchr 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
"mkdir 0.0.1",
"mkfifo 0.0.1",
@ -448,6 +449,16 @@ dependencies = [
"uucore 0.0.1",
]
[[package]]
name = "ls"
version = "0.0.1"
dependencies = [
"getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
"pretty-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"uucore 0.0.1",
]
[[package]]
name = "memchr"
version = "0.1.7"
@ -571,6 +582,15 @@ dependencies = [
"uucore 0.0.1",
]
[[package]]
name = "pretty-bytes"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "primal"
version = "0.2.3"

View file

@ -146,6 +146,7 @@ TEST_PROGS := \
head \
link \
ln \
ls \
mkdir \
mktemp \
mv \

View file

@ -89,8 +89,7 @@ fn help() {
fn list(options: getopts::Matches) {
let locs: Vec<String> = if options.free.is_empty() {
show_error!("Missing DIRECTORY or FILES argument. Try --help.");
panic!();
vec![String::from(".")]
} else {
options.free.iter().cloned().collect()
};

16
tests/ls.rs Normal file
View file

@ -0,0 +1,16 @@
#[macro_use]
mod common;
use common::util::*;
static UTIL_NAME: &'static str = "ls";
#[test]
fn test_ls_ls() {
let (at, mut ucmd) = testing(UTIL_NAME);
let result = ucmd.run();
let exit_success = result.success;
assert_eq!(exit_success, true);
}