diff --git a/Cargo.lock b/Cargo.lock index d8fa3e1..2808103 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -23,16 +23,13 @@ dependencies = [ ] [[package]] -name = "assert_cli" -version = "0.6.2" +name = "assert_cmd" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "colored 1.6.1 (registry+https://github.com/rust-lang/crates.io-index)", - "difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "environment 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "failure_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.22 (registry+https://github.com/rust-lang/crates.io-index)", + "escargot 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "predicates 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -138,14 +135,6 @@ dependencies = [ "vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "colored" -version = "1.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "lazy_static 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "crossbeam" version = "0.3.2" @@ -210,11 +199,6 @@ name = "either" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "environment" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "error-chain" version = "0.1.12" @@ -231,6 +215,15 @@ dependencies = [ "backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "escargot" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "serde 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.22 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "failure" version = "0.1.1" @@ -260,6 +253,14 @@ dependencies = [ "redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "float-cmp" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "num-traits 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "fnv" version = "1.0.6" @@ -441,7 +442,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" name = "mesabox" version = "0.1.0" dependencies = [ - "assert_cli 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "assert_cmd 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "chrono 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -459,6 +460,7 @@ dependencies = [ "nom 4.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "platform-info 0.1.0 (git+https://github.com/uutils/platform-info)", "pnet 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)", + "predicates 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "rustyline 2.0.0-alpha (git+https://github.com/kkawakam/rustyline)", "socket2 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -662,6 +664,24 @@ dependencies = [ "pnet_sys 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "predicates" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "float-cmp 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "proc-macro2" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "quick-error" version = "1.2.2" @@ -672,6 +692,14 @@ name = "quote" version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "quote" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "rand" version = "0.4.2" @@ -792,6 +820,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" name = "serde" version = "1.0.70" source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "serde_derive 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "serde_derive" +version = "1.0.70" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.14.4 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] name = "serde_json" @@ -839,6 +880,16 @@ dependencies = [ "unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "syn" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "synom" version = "0.11.3" @@ -1166,6 +1217,11 @@ name = "unicode-xid" version = "0.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "unicode-xid" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "unreachable" version = "1.0.0" @@ -1292,7 +1348,7 @@ dependencies = [ "checksum aho-corasick 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "f0ba20154ea1f47ce2793322f049c5646cc6d0fa9759d5f333f286e507bf8080" "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" "checksum arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "a1e964f9e24d588183fcb43503abda40d288c8657dfc27311516ce2f05675aef" -"checksum assert_cli 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "98589b0e465a6c510d95fceebd365bb79bedece7f6e18a480897f2015f85ec51" +"checksum assert_cmd 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f1ab456fa53d12b810a6e042654df36b30933f786c00e170099f68b469f75084" "checksum atty 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "2fc4a1aa4c24c0718a250f0681885c1af91419d242f29eb8f2ab28502d80dbd1" "checksum backtrace 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "346d7644f0b5f9bc73082d3b2236b69a05fd35cce0cfa3724e184e6a5c9e2a2f" "checksum backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "89a47830402e9981c5c41223151efcced65a0510c13097c769cede7efb34782a" @@ -1305,7 +1361,6 @@ dependencies = [ "checksum cfg-if 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "efe5c877e17a9c717a0bf3613b2709f723202c4e4675cc8f12926ded29bcb17e" "checksum chrono 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "6962c635d530328acc53ac6a955e83093fedc91c5809dfac1fa60fa470830a37" "checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e" -"checksum colored 1.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dc0a60679001b62fb628c4da80e574b9645ab4646056d7c9018885efffe45533" "checksum crossbeam 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "24ce9782d4d5c53674646a6a4c1863a21a8fc0cb649b3c94dfc16e45071dea19" "checksum crossbeam-deque 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fe8153ef04a7594ded05b427ffad46ddeaf22e63fd48d42b3e1e3bb4db07cae7" "checksum crossbeam-epoch 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2af0e75710d6181e234c8ecc79f14a97907850a541b13b0be1dd10992f2e4620" @@ -1315,12 +1370,13 @@ dependencies = [ "checksum difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198" "checksum dtoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6d301140eb411af13d3115f9a562c85cc6b541ade9dfa314132244aaee7489dd" "checksum either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3be565ca5c557d7f59e7cfcf1844f9e3033650c929c6566f511e8005f205c1d0" -"checksum environment 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1f4b14e20978669064c33b4c1e0fb4083412e40fe56cbea2eae80fd7591503ee" "checksum error-chain 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "faa976b4fd2e4c2b2f3f486874b19e61944d3de3de8b61c9fcf835d583871bcc" "checksum error-chain 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6930e04918388a9a2e41d518c25cf679ccafe26733fb4127dbf21993f2575d46" +"checksum escargot 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ddeb6acd0f12aeba309aa295bcad6d4d88603406640bf2595c887a7a9684a4bd" "checksum failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "934799b6c1de475a012a02dab0ace1ace43789ee4b99bcfbf1a2e3e8ced5de82" "checksum failure_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c7cdda555bb90c9bb67a3b670a0f42de8e73f5981524123ad8578aafec8ddb8b" "checksum filetime 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "da4b9849e77b13195302c174324b5ba73eec9b236b24c221a61000daefb95c5f" +"checksum float-cmp 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "134a8fa843d80a51a5b77d36d42bc2def9edcb0262c914861d08129fd1926600" "checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" "checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" "checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" @@ -1367,8 +1423,11 @@ dependencies = [ "checksum pnet_packet 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ef99f3cfa2c0ed07e9ad6d9f788592d863361a8dd3102989d79b0f6a787ba434" "checksum pnet_sys 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)" = "963b9109a05c3ac370abc3fda61bff20d03743c2947942173871b9cac2b9acb0" "checksum pnet_transport 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)" = "568a118fe2f74ebb08e9b9b6ac812b9730a7b043c5ca4d97325f4edeb018cae0" +"checksum predicates 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6c87e42b16f01ca45f0eaa339080b18491a3b8b99cb2bf111de1d7edcb3914a1" +"checksum proc-macro2 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "effdb53b25cdad54f8f48843d67398f7ef2e14f12c1b4cb4effc549a6462a4d6" "checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" "checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a" +"checksum quote 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e44651a0dc4cdd99f71c83b561e221f714912d11af1a4dff0631f923d53af035" "checksum rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "eba5f8cb59cc50ed56be8880a5c7b496bfd9bd26394e176bc67884094145c2c5" "checksum redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "c214e91d3ecf43e9a4e41e578973adeb14b474f2bee858742d127af75a0112b1" "checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" @@ -1384,12 +1443,14 @@ dependencies = [ "checksum same-file 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "cfb6eded0b06a0b512c8ddbcf04089138c9b4362c2f696f3c3d76039d68f3637" "checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" "checksum serde 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)" = "0c3adf19c07af6d186d91dae8927b83b0553d07ca56cbf7f2f32560455c91920" +"checksum serde_derive 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)" = "3525a779832b08693031b8ecfb0de81cd71cfd3812088fafe9a7496789572124" "checksum serde_json 1.0.22 (registry+https://github.com/rust-lang/crates.io-index)" = "84b8035cabe9b35878adec8ac5fe03d5f6bc97ff6edd7ccb96b44c1276ba390e" "checksum slab 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fdeff4cd9ecff59ec7e3744cbca73dfe5ac35c2aedb2cfba8a1c715a18912e9d" "checksum smallvec 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "312a7df010092e73d6bbaf141957e868d4f30efd2bfd9bb1028ad91abec58514" "checksum socket2 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "962a516af4d3a7c272cb3a1d50a8cc4e5b41802e4ad54cfb7bee8ba61d37d703" "checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550" "checksum syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad" +"checksum syn 0.14.4 (registry+https://github.com/rust-lang/crates.io-index)" = "2beff8ebc3658f07512a413866875adddd20f4fd47b2a4e6c9da65cd281baaea" "checksum synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6" "checksum synstructure 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3a761d12e6d8dcb4dcf952a7a89b475e3a9d69e4a69307e01a470977642914bd" "checksum syntex 0.42.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0a30b08a6b383a22e5f6edc127d169670d48f905bb00ca79a00ea3e442ebe317" @@ -1422,6 +1483,7 @@ dependencies = [ "checksum unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "882386231c45df4700b275c7ff55b6f3698780a650026380e72dabe76fa46526" "checksum unicode-xid 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "36dff09cafb4ec7c8cf0023eb0b686cb6ce65499116a12201c9e11840ca01beb" "checksum unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc" +"checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" "checksum unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "382810877fe448991dfc7f0dd6e3ae5d58088fd0ea5e35189655f84e6814fa56" "checksum url 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f808aadd8cfec6ef90e4a14eb46f24511824d1ac596b9682703c87056c8678b7" "checksum utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "662fab6525a98beff2921d7f61a39e7d59e0b425ebc7d0d9e66d316e55124122" diff --git a/Cargo.toml b/Cargo.toml index 3d5b5be..cea0736 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -84,7 +84,8 @@ rustyline = { git = "https://github.com/kkawakam/rustyline", optional = true } tempfile = "3.0.2" libc = "0.2.40" lazy_static = "1.0.1" -assert_cli = "0.6.2" +assert_cmd = "0.5.0" +predicates = "0.5.1" [profile.release] lto = true diff --git a/tests/gnu/test_arch.rs b/tests/gnu/test_arch.rs index be8f147..45cfd8a 100644 --- a/tests/gnu/test_arch.rs +++ b/tests/gnu/test_arch.rs @@ -6,34 +6,35 @@ // For a copy, see the LICENSE file. // -use assert_cli; +use std::process::Command; +use assert_cmd::prelude::*; #[test] #[cfg(target_arch = "x86_64")] fn test_x86_64() { - new_cli!() - .succeeds() - .and() - .stdout().is("x86_64\n") - .unwrap(); + new_cmd!() + .assert() + .success() + .stdout("x86_64\n") + .stderr(""); } #[test] #[cfg(target_arch = "arm")] fn test_arm() { - new_cli!() - .succeeds() - .and() - .stdout().is("arm\n") - .unwrap(); + new_cmd!() + .assert() + .success() + .stdout("arm\n") + .stderr(""); } #[test] #[cfg(target_arch = "aarch64")] fn test_aarch64() { - new_cli!() - .succeeds() - .and() - .stdout().is("aarch64\n") - .unwrap(); + new_cmd!() + .assert() + .success() + .stdout("aarch64\n") + .stderr(""); } diff --git a/tests/gnu/test_base32.rs b/tests/gnu/test_base32.rs index 28212c6..52b9170 100644 --- a/tests/gnu/test_base32.rs +++ b/tests/gnu/test_base32.rs @@ -32,60 +32,58 @@ // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -use assert_cli; +use assert_cmd::prelude::*; +use predicates::prelude::*; +use std::process::Command; #[test] fn test_encode() { let input = "Hello, World!"; - new_cli!() - .stdin(input) - .succeeds() - .and() - .stdout().is("JBSWY3DPFQQFO33SNRSCC===\n") - .stderr().is("") - .unwrap(); + new_cmd!() + .with_stdin(input) + .assert() + .success() + .stdout("JBSWY3DPFQQFO33SNRSCC===\n") + .stderr(""); } #[test] fn test_decode() { for decode_param in vec!["-d", "--decode"] { let input = "JBSWY3DPFQQFO33SNRSCC===\n"; - new_cli!() - .with_args(&[decode_param]) - .stdin(input) - .succeeds() - .and() - .stdout().is("Hello, World!") - .stderr().is("") - .unwrap(); + new_cmd!() + .arg(decode_param) + .with_stdin(input) + .assert() + .success() + .stdout("Hello, World!") + .stderr(""); } } #[test] fn test_garbage() { let input = "aGVsbG8sIHdvcmxkIQ==\0"; - new_cli!() - .with_args(&["-d"]) - .stdin(input) - .fails() - .and() - .stdout().is("") - .stderr().contains("invalid length at 16") - .unwrap(); + new_cmd!() + .arg("-d") + .with_stdin(input) + .assert() + .failure() + .stdout("") + .stderr(predicate::str::contains("invalid length at 16").from_utf8()); } #[test] fn test_ignore_garbage() { for ignore_garbage_param in vec!["-i", "--ignore-garbage"] { let input = "JBSWY\x013DPFQ\x02QFO33SNRSCC===\n"; - new_cli!() - .with_args(&["-d", ignore_garbage_param]) - .stdin(input) - .succeeds() - .and() - .stdout().is("Hello, World!") - .stderr().is("") - .unwrap(); + new_cmd!() + .args(&["-d", ignore_garbage_param]) + .with_stdin(input) + .assert() + .success() + .stdout("Hello, World!") + .stderr(""); } } @@ -93,39 +91,36 @@ fn test_ignore_garbage() { fn test_wrap() { for wrap_param in vec!["-w", "--wrap"] { let input = "The quick brown fox jumps over the lazy dog."; - new_cli!() - .with_args(&[wrap_param, "20"]) - .stdin(input) - .succeeds() - .and() - .stdout().is("KRUGKIDROVUWG2ZAMJZG\n653OEBTG66BANJ2W24DT\nEBXXMZLSEB2GQZJANRQX\nU6JAMRXWOLQ=\n") - .stderr().is("") - .unwrap(); + new_cmd!() + .args(&[wrap_param, "20"]) + .with_stdin(input) + .assert() + .success() + .stdout("KRUGKIDROVUWG2ZAMJZG\n653OEBTG66BANJ2W24DT\nEBXXMZLSEB2GQZJANRQX\nU6JAMRXWOLQ=\n") + .stderr(""); } } #[test] fn test_wrap_no_arg() { for wrap_param in vec!["-w", "--wrap"] { - new_cli!() - .with_args(&[wrap_param]) - .fails() - .and() - .stdout().is("") - .stderr().contains("requires a value but none was supplied\n") - .unwrap(); + new_cmd!() + .arg(wrap_param) + .assert() + .failure() + .stdout("") + .stderr(predicate::str::contains("requires a value but none was supplied\n").from_utf8()); } } #[test] fn test_wrap_bad_arg() { for wrap_param in vec!["-w", "--wrap"] { - new_cli!() - .with_args(&[wrap_param, "b"]) - .fails() - .and() - .stdout().is("") - .stderr().contains("'b' is not a number\n") - .unwrap(); + new_cmd!() + .args(&[wrap_param, "b"]) + .assert() + .failure() + .stdout("") + .stderr(predicate::str::contains("'b' is not a number\n").from_utf8()); } } diff --git a/tests/gnu/test_base64.rs b/tests/gnu/test_base64.rs index fc16660..b1b6b7e 100644 --- a/tests/gnu/test_base64.rs +++ b/tests/gnu/test_base64.rs @@ -32,60 +32,58 @@ // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -use assert_cli; +use assert_cmd::prelude::*; +use predicates::prelude::*; +use std::process::Command; #[test] fn test_encode() { let input = "hello, world!"; - new_cli!() - .stdin(input) - .succeeds() - .and() - .stdout().is("aGVsbG8sIHdvcmxkIQ==\n") - .stderr().is("") - .unwrap(); + new_cmd!() + .with_stdin(input) + .assert() + .success() + .stdout("aGVsbG8sIHdvcmxkIQ==\n") + .stderr(""); } #[test] fn test_decode() { for decode_param in vec!["-d", "--decode"] { let input = "aGVsbG8sIHdvcmxkIQ=="; - new_cli!() - .with_args(&[decode_param]) - .stdin(input) - .succeeds() - .and() - .stdout().is("hello, world!") - .stderr().is("") - .unwrap(); + new_cmd!() + .arg(decode_param) + .with_stdin(input) + .assert() + .success() + .stdout("hello, world!") + .stderr(""); } } #[test] fn test_garbage() { let input = "aGVsbG8sIHdvcmxkIQ==\0"; - new_cli!() - .with_args(&["-d"]) - .stdin(input) - .fails() - .and() - .stdout().is("") - .stderr().contains("invalid length at 20") - .unwrap(); + new_cmd!() + .arg("-d") + .with_stdin(input) + .assert() + .failure() + .stderr(predicate::str::contains("invalid length at 20").from_utf8()) + .stdout(""); } #[test] fn test_ignore_garbage() { for ignore_garbage_param in vec!["-i", "--ignore-garbage"] { let input = "aGVsbG8sIHdvcmxkIQ==\0"; - new_cli!() - .with_args(&["-d", ignore_garbage_param]) - .stdin(input) - .succeeds() - .and() - .stdout().is("hello, world!") - .stderr().is("") - .unwrap(); + new_cmd!() + .args(&["-d", ignore_garbage_param]) + .with_stdin(input) + .assert() + .success() + .stdout("hello, world!") + .stderr(""); } } @@ -93,39 +91,36 @@ fn test_ignore_garbage() { fn test_wrap() { for wrap_param in vec!["-w", "--wrap"] { let input = "The quick brown fox jumps over the lazy dog."; - new_cli!() - .with_args(&[wrap_param, "20"]) - .stdin(input) - .succeeds() - .and() - .stdout().is("VGhlIHF1aWNrIGJyb3du\nIGZveCBqdW1wcyBvdmVy\nIHRoZSBsYXp5IGRvZy4=\n") - .stderr().is("") - .unwrap(); + new_cmd!() + .args(&[wrap_param, "20"]) + .with_stdin(input) + .assert() + .success() + .stdout("VGhlIHF1aWNrIGJyb3du\nIGZveCBqdW1wcyBvdmVy\nIHRoZSBsYXp5IGRvZy4=\n") + .stderr(""); } } #[test] fn test_wrap_no_arg() { for wrap_param in vec!["-w", "--wrap"] { - new_cli!() - .with_args(&[wrap_param]) - .fails() - .and() - .stdout().is("") - .stderr().contains("requires a value but none was supplied\n") - .unwrap(); + new_cmd!() + .arg(wrap_param) + .assert() + .failure() + .stdout("") + .stderr(predicate::str::contains("requires a value but none was supplied").from_utf8()); } } #[test] fn test_wrap_bad_arg() { for wrap_param in vec!["-w", "--wrap"] { - new_cli!() - .with_args(&[wrap_param, "b"]) - .fails() - .and() - .stdout().is("") - .stderr().contains("'b' is not a number\n") - .unwrap(); + new_cmd!() + .args(&[wrap_param, "b"]) + .assert() + .failure() + .stdout("") + .stderr(predicate::str::contains("'b' is not a number\n").from_utf8()); } } diff --git a/tests/macros.rs b/tests/macros.rs index a20625e..4144c74 100644 --- a/tests/macros.rs +++ b/tests/macros.rs @@ -90,10 +90,9 @@ macro_rules! util_name { } #[macro_export] -macro_rules! new_cli { +macro_rules! new_cmd { () => { - assert_cli::Assert::main_binary() - .with_args(&[util_name!()]) + Command::main_binary().unwrap().arg(util_name!()) }; } diff --git a/tests/posix/test_cat.rs b/tests/posix/test_cat.rs index 079c7c6..b8717d5 100644 --- a/tests/posix/test_cat.rs +++ b/tests/posix/test_cat.rs @@ -31,17 +31,18 @@ // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -use assert_cli; +use assert_cmd::prelude::*; +use predicates::prelude::*; +use std::process::Command; #[test] fn test_output_multi_files_print_all_chars() { - new_cli!() + new_cmd!() .current_dir(fixtures_path!()) - .with_args(&["alpha.txt", "256.txt", "-A", "-n"]) - .succeeds() - .and() - .stderr().is("") - .stdout().is(" 1\tabcde$\n 2\tfghij$\n 3\tklmno$\n 4\tpqrst$\n \ + .args(&["alpha.txt", "256.txt", "-A", "-n"]) + .assert() + .success() + .stdout(" 1\tabcde$\n 2\tfghij$\n 3\tklmno$\n 4\tpqrst$\n \ 5\tuvwxyz$\n 6\t^@^A^B^C^D^E^F^G^H^I$\n \ 7\t^K^L^M^N^O^P^Q^R^S^T^U^V^W^X^Y^Z^[^\\^]^^^_ \ !\"#$%&\'()*+,-./0123456789:;\ @@ -52,151 +53,145 @@ fn test_output_multi_files_print_all_chars() { M-;M-M-?M-@M-AM-BM-CM-DM-EM-FM-GM-HM-IM-JM-KM-LM-MM-NM-OM-PM-QM-RM-SM-TM-U\ M-VM-WM-XM-YM-ZM-[M-\\M-]M-^M-_M-`M-aM-bM-cM-dM-eM-fM-gM-hM-iM-jM-kM-lM-mM-nM-oM-\ pM-qM-rM-sM-tM-uM-vM-wM-xM-yM-zM-{M-|M-}M-~M-^?") - .unwrap(); + .stderr(""); } #[test] fn test_numbered_lines_no_trailing_newline() { - new_cli!() + new_cmd!() .current_dir(fixtures_path!()) - .with_args(&["nonewline.txt", "alpha.txt", "-n"]) - .succeeds() - .and() - .stderr().is("") - .stdout().is(" 1\ttext without a trailing newlineabcde\n 2\tfghij\n \ + .args(&["nonewline.txt", "alpha.txt", "-n"]) + .assert() + .success() + .stdout(" 1\ttext without a trailing newlineabcde\n 2\tfghij\n \ 3\tklmno\n 4\tpqrst\n 5\tuvwxyz\n") - .unwrap(); + .stderr(""); } #[test] -fn test_stdin_show_nonprinting() { +fn test_with_stdin_show_nonprinting() { for same_param in vec!["-v", "--show-nonprinting"] { - new_cli!() - .with_args(&[same_param]) - .stdin("\t\0\n") - .succeeds() - .and() - .stderr().is("") - .stdout().is("\t^@\n") - .unwrap(); + new_cmd!() + .args(&[same_param]) + .with_stdin("\t\0\n") + .assert() + .success() + .stdout("\t^@\n") + .stderr(""); } } #[test] -fn test_stdin_show_tabs() { +fn test_with_stdin_show_tabs() { for same_param in vec!["-T", "--show-tabs"] { - new_cli!() - .with_args(&[same_param]) - .stdin("\t\0\n") - .succeeds() - .and() - .stderr().is("") - .stdout().is("^I\0\n") - .unwrap(); + new_cmd!() + .args(&[same_param]) + .with_stdin("\t\0\n") + .assert() + .success() + .stdout("^I\0\n") + .stderr(""); } } #[test] -fn test_stdin_show_ends() { +fn test_with_stdin_show_ends() { for same_param in vec!["-E", "--show-ends"] { - new_cli!() - .with_args(&[same_param,"-"]) - .stdin("\t\0\n") - .succeeds() - .and() - .stderr().is("") - .stdout().is("\t\0$\n") - .unwrap(); + new_cmd!() + .args(&[same_param,"-"]) + .with_stdin("\t\0\n") + .assert() + .success() + .stdout("\t\0$\n") + .stderr(""); } } #[test] -fn test_stdin_show_all() { +fn test_with_stdin_show_all() { for same_param in vec!["-A", "--show-all"] { - new_cli!() - .with_args(&[same_param]) - .stdin("\t\0\n") - .succeeds() - .and() - .stderr().is("") - .stdout().is("^I^@$\n") - .unwrap(); + new_cmd!() + .args(&[same_param]) + .with_stdin("\t\0\n") + .assert() + .success() + .stdout("^I^@$\n") + .stderr(""); } } #[test] -fn test_stdin_nonprinting_and_endofline() { - new_cli!() - .with_args(&["-e"]) - .stdin("\t\0\n") - .succeeds() - .and() - .stderr().is("") - .stdout().is("\t^@$\n") - .unwrap(); +fn test_with_stdin_nonprinting_and_endofline() { + new_cmd!() + .args(&["-e"]) + .with_stdin("\t\0\n") + .assert() + .success() + .stdout("\t^@$\n") + .stderr(""); } #[test] -fn test_stdin_nonprinting_and_tabs() { - new_cli!() - .with_args(&["-t"]) - .stdin("\t\0\n") - .succeeds() - .stderr().is("") - .stdout().is("^I^@\n") - .unwrap(); +fn test_with_stdin_nonprinting_and_tabs() { + new_cmd!() + .args(&["-t"]) + .with_stdin("\t\0\n") + .assert() + .success() + .stdout("^I^@\n") + .stderr(""); } #[test] -fn test_stdin_squeeze_blank() { +fn test_with_stdin_squeeze_blank() { for same_param in vec!["-s", "--squeeze-blank"] { - new_cli!() - .with_args(&[same_param]) - .stdin("\n\na\n\n\n\n\nb\n\n\n") - .succeeds() - .stderr().is("") - .stdout().is("\na\n\nb\n\n") - .unwrap(); + new_cmd!() + .args(&[same_param]) + .with_stdin("\n\na\n\n\n\n\nb\n\n\n") + .assert() + .success() + .stdout("\na\n\nb\n\n") + .stderr(""); } } #[test] -fn test_stdin_number_non_blank() { +fn test_with_stdin_number_non_blank() { for same_param in vec!["-b", "--number-nonblank"] { - new_cli!() - .with_args(&[same_param, "-"]) - .stdin("\na\nb\n\n\nc") - .succeeds() - .stderr().is("") - .stdout().is("\n 1\ta\n 2\tb\n\n\n 3\tc") - .unwrap(); + new_cmd!() + .args(&[same_param, "-"]) + .with_stdin("\na\nb\n\n\nc") + .assert() + .success() + .stdout("\n 1\ta\n 2\tb\n\n\n 3\tc") + .stderr(""); } } #[test] fn test_non_blank_overrides_number() { for same_param in vec!["-b", "--number-nonblank"] { - new_cli!() - .with_args(&[same_param, "-"]) - .stdin("\na\nb\n\n\nc") - .succeeds() - .stderr().is("") - .stdout().is("\n 1\ta\n 2\tb\n\n\n 3\tc") - .unwrap(); + new_cmd!() + .args(&[same_param, "-"]) + .with_stdin("\na\nb\n\n\nc") + .assert() + .success() + .stdout("\n 1\ta\n 2\tb\n\n\n 3\tc") + .stderr(""); } } #[test] fn test_squeeze_blank_before_numbering() { for same_param in vec!["-s", "--squeeze-blank"] { - new_cli!() - .with_args(&[same_param, "-n", "-"]) - .stdin("a\n\n\nb") - .succeeds() - .stderr().is("") - .stdout().is(" 1\ta\n 2\t\n 3\tb") - .unwrap(); + new_cmd!() + .args(&[same_param, "-n", "-"]) + .with_stdin("a\n\n\nb") + .assert() + .success() + .stdout(" 1\ta\n 2\t\n 3\tb") + .stderr(""); } } @@ -218,12 +213,12 @@ fn test_domain_socket() { stream.write_all(b"a\tb").expect("failed to write test data"); }); - new_cli!() - .with_args(&[socket_path]) - .succeeds() - .stderr().is("") - .stdout().is("a\tb") - .unwrap(); + new_cmd!() + .args(&[socket_path]) + .assert() + .success() + .stdout("a\tb") + .stderr(""); thread.join().unwrap(); } diff --git a/tests/tests.rs b/tests/tests.rs index a57696f..f0f99bd 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -11,8 +11,8 @@ extern crate mesabox; extern crate lazy_static; extern crate libc; extern crate tempfile; -#[macro_use] -extern crate assert_cli; +extern crate assert_cmd; +extern crate predicates; mod util; #[macro_use]