wip: using trycmd to test the CLI
diff --git a/Cargo.lock b/Cargo.lock index 48560b3..e42b1dc 100644 --- a/Cargo.lock +++ b/Cargo.lock
@@ -82,6 +82,12 @@ ] [[package]] +name = "bytes" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8" + +[[package]] name = "bytesize" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -163,6 +169,7 @@ "tempfile", "termcolor", "toml", + "trycmd", ] [[package]] @@ -227,6 +234,16 @@ ] [[package]] +name = "combine" +version = "4.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2b2f5d0ee456f3928812dfc8c6d9a1d592b98678f6d56db9b0cd2b7bc6c8db5" +dependencies = [ + "bytes", + "memchr", +] + +[[package]] name = "commoncrypto" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -245,6 +262,23 @@ ] [[package]] +name = "concolor-control" +version = "0.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7104119c2f80d887239879d0c50e033cd40eac9a3f3561e0684ba7d5d654f4da" +dependencies = [ + "atty", + "bitflags", + "concolor-query", +] + +[[package]] +name = "concolor-query" +version = "0.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad159cc964ac8f9d407cbc0aa44b02436c054b541f2b4b5f06972e1efdc54bc7" + +[[package]] name = "core-foundation" version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -284,6 +318,40 @@ ] [[package]] +name = "crossbeam-channel" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06ed27e177f16d65f0f0c22a213e17c696ace5dd64b14258b52f9417ccb52db4" +dependencies = [ + "cfg-if", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6455c0ca19f0d2fbf751b908d5c55c1f5cbc65e03c4225427254b46890bdde1e" +dependencies = [ + "cfg-if", + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ec02e091aa634e2c3ada4a392989e7c3116673ef0ac5b72232439094d73b7fd" +dependencies = [ + "cfg-if", + "crossbeam-utils", + "lazy_static", + "memoffset", + "scopeguard", +] + +[[package]] name = "crossbeam-utils" version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -337,6 +405,12 @@ ] [[package]] +name = "difflib" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6184e33543162437515c2e2b48714794e37845ec9851711914eec9d308f6ebe8" + +[[package]] name = "either" version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -479,6 +553,12 @@ ] [[package]] +name = "hashbrown" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" + +[[package]] name = "hermit-abi" version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -515,6 +595,16 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] +name = "humantime-serde" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac34a56cfd4acddb469cc7fff187ed5ac36f498ba085caf8bbc725e3ff474058" +dependencies = [ + "humantime", + "serde", +] + +[[package]] name = "idna" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -558,6 +648,16 @@ ] [[package]] +name = "indexmap" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc633605454125dec4b66843673f01c7df2b89479b32e0ed634e43a91cff62a5" +dependencies = [ + "autocfg", + "hashbrown", +] + +[[package]] name = "itertools" version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -582,6 +682,15 @@ ] [[package]] +name = "kstring" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b310ccceade8121d7d77fee406160e457c2f4e7c7982d589da3499bc7ea4526" +dependencies = [ + "serde", +] + +[[package]] name = "lazy_static" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -671,6 +780,15 @@ checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" [[package]] +name = "memoffset" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59accc507f1338036a0477ef61afdae33cde60840f4dfe481319ce3ad116ddf9" +dependencies = [ + "autocfg", +] + +[[package]] name = "miniz_oxide" version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -690,6 +808,12 @@ ] [[package]] +name = "normalize-line-endings" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be" + +[[package]] name = "num_cpus" version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -759,6 +883,16 @@ ] [[package]] +name = "os_pipe" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb233f06c2307e1f5ce2ecad9f8121cffbbee2c95428f44ea85222e460d0d213" +dependencies = [ + "libc", + "winapi", +] + +[[package]] name = "percent-encoding" version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -850,6 +984,31 @@ ] [[package]] +name = "rayon" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c06aca804d41dbc8ba42dfd964f0d01334eceb64314b9ecf7c5fad5188a06d90" +dependencies = [ + "autocfg", + "crossbeam-deque", + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d78120e2c850279833f1dd3582f730c4ab53ed95aeaaaa862a2a5c71b1656d8e" +dependencies = [ + "crossbeam-channel", + "crossbeam-deque", + "crossbeam-utils", + "lazy_static", + "num_cpus", +] + +[[package]] name = "redox_syscall" version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -934,6 +1093,12 @@ ] [[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + +[[package]] name = "semver" version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -989,6 +1154,12 @@ checksum = "45bb67a18fa91266cc7807181f62f9178a6873bfad7dc788c42e6430db40184f" [[package]] +name = "shlex" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3" + +[[package]] name = "sized-chunks" version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1119,6 +1290,42 @@ ] [[package]] +name = "toml_edit" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c29c21e11af3c58476a1063cb550e255c45c60928bf7f272462a533e7a2b406" +dependencies = [ + "combine", + "indexmap", + "itertools", + "kstring", + "serde", +] + +[[package]] +name = "trycmd" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c87a4f2e0995588f75fff612ab2ad988ee8ff749a2d2fa8518e5c20ea1175307" +dependencies = [ + "concolor-control", + "difflib", + "glob", + "humantime", + "humantime-serde", + "normalize-line-endings", + "os_pipe", + "rayon", + "serde", + "shlex", + "tempfile", + "toml_edit", + "wait-timeout", + "walkdir", + "yansi", +] + +[[package]] name = "typenum" version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1209,6 +1416,15 @@ ] [[package]] +name = "wait-timeout" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f200f5b12eb75f8c1ed65abd4b2db8a6e1b138a20de009dacee265a2498f3f6" +dependencies = [ + "libc", +] + +[[package]] name = "walkdir" version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1255,3 +1471,9 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "yansi" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fc79f4a1e39857fc00c3f662cbf2651c771f00e9c15fe2abc341806bd46bd71"
diff --git a/Cargo.toml b/Cargo.toml index 8835356..6fc52d2 100644 --- a/Cargo.toml +++ b/Cargo.toml
@@ -41,6 +41,9 @@ toml = "~0.5.0" clap = "2.33.3" +[dev-dependencies] +trycmd = "0.7" + [dependencies.termcolor] optional = true version = "1.0"
diff --git a/tests/cli.rs b/tests/cli.rs new file mode 100644 index 0000000..b95bfae --- /dev/null +++ b/tests/cli.rs
@@ -0,0 +1,7 @@ +#[test] +fn cli_test() { + let t = trycmd::TestCases::new(); + t.case("tests/cmd/*.md") + .case("tests/cmd/*.trycmd") + .case("tests/cmd/*.toml"); +}
diff --git a/tests/cmd/basic.stderr b/tests/cmd/basic.stderr new file mode 100644 index 0000000..55f4d73 --- /dev/null +++ b/tests/cmd/basic.stderr
@@ -0,0 +1,6 @@ +error: 'cargo' requires a subcommand, but one was not provided + +USAGE: + cargo <SUBCOMMAND> + +For more information try --help
diff --git a/tests/cmd/basic.stdout b/tests/cmd/basic.stdout new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/cmd/basic.stdout
diff --git a/tests/cmd/basic.trycmd b/tests/cmd/basic.trycmd new file mode 100644 index 0000000..a33016e --- /dev/null +++ b/tests/cmd/basic.trycmd
@@ -0,0 +1,43 @@ +```bash +$ cargo-outdated +? 1 +error: 'cargo' requires a subcommand, but one was not provided + +USAGE: + cargo <SUBCOMMAND> + +For more information try --help +``` + + +```bash +$ cargo-outdated outdated -h +cargo-outdated [..] +Displays information about project dependency versions + +USAGE: + cargo outdated [OPTIONS] + +OPTIONS: + -a, --aggresssive Ignores channels for latest updates + --color <COLOR> Output coloring [default: auto] [possible values: Auto, Never, Always] + -d, --depth <NUM> How deep in the dependency chain to search (Defaults to all dependencies when + omitted) + -x, --exclude <DEPENDENCIES> Dependencies to exclude from building (comma separated or one per '--exclude' + argument) + --exit-code <NUM> The exit code to return on new versions found [default: 0] + --features <FEATURES>... Space-separated list of features + --format <FORMAT> Output formatting [default: list] [possible values: List, Json] + -h, --help Prints help information + -i, --ignore <DEPENDENCIES> Dependencies to not print in the output (comma separated or one per '--ignore' + argument) + -m, --manifest-path <PATH> Path to the Cargo.toml file to use (Defaults to Cargo.toml in project root) + -o, --offline Run without accessing the network (useful for testing w/ local registries) + -p, --packages <PKGS> Packages to inspect for updates (comma separated or one per '--packages' argument) + -q, --quiet Suppresses warnings + -r, --root <ROOT> Package to treat as the root package + -R, --root-deps-only Only check root dependencies (Equivalent to --depth=1) + -V, --version Prints version information + -v, --verbose Use verbose output + -w, --workspace Checks updates for all workspace members rather than only the root package +```