diff --git a/Cargo.lock b/Cargo.lock index db6789500..f2fca3c8a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -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" diff --git a/Makefile b/Makefile index be959977e..ca7ef25f6 100644 --- a/Makefile +++ b/Makefile @@ -146,6 +146,7 @@ TEST_PROGS := \ head \ link \ ln \ + ls \ mkdir \ mktemp \ mv \ diff --git a/src/ls/ls.rs b/src/ls/ls.rs index 3d5453ec2..2e71e7b24 100644 --- a/src/ls/ls.rs +++ b/src/ls/ls.rs @@ -89,8 +89,7 @@ fn help() { fn list(options: getopts::Matches) { let locs: Vec = if options.free.is_empty() { - show_error!("Missing DIRECTORY or FILES argument. Try --help."); - panic!(); + vec![String::from(".")] } else { options.free.iter().cloned().collect() }; diff --git a/tests/ls.rs b/tests/ls.rs new file mode 100644 index 000000000..36d98eea1 --- /dev/null +++ b/tests/ls.rs @@ -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); +} \ No newline at end of file