mirror of
https://github.com/crate-ci/typos.git
synced 2024-11-25 10:31:02 -05:00
test: Port to trycmd
This commit is contained in:
parent
a8ae8a5c26
commit
9446008676
14 changed files with 115 additions and 80 deletions
118
Cargo.lock
generated
118
Cargo.lock
generated
|
@ -58,20 +58,6 @@ version = "0.5.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b"
|
checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "assert_cmd"
|
|
||||||
version = "2.0.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "e996dc7940838b7ef1096b882e29ec30a3149a3a443cdc8dba19ed382eca1fe2"
|
|
||||||
dependencies = [
|
|
||||||
"bstr",
|
|
||||||
"doc-comment",
|
|
||||||
"predicates",
|
|
||||||
"predicates-core",
|
|
||||||
"predicates-tree",
|
|
||||||
"wait-timeout",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "assert_fs"
|
name = "assert_fs"
|
||||||
version = "1.0.6"
|
version = "1.0.6"
|
||||||
|
@ -154,6 +140,12 @@ version = "3.7.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d9df67f7bf9ef8498769f994239c45613ef0c5899415fb58e9add412d2c1a538"
|
checksum = "d9df67f7bf9ef8498769f994239c45613ef0c5899415fb58e9add412d2c1a538"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bytes"
|
||||||
|
version = "1.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cast"
|
name = "cast"
|
||||||
version = "0.2.7"
|
version = "0.2.7"
|
||||||
|
@ -231,6 +223,16 @@ dependencies = [
|
||||||
"unicase",
|
"unicase",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "combine"
|
||||||
|
version = "4.6.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b2b2f5d0ee456f3928812dfc8c6d9a1d592b98678f6d56db9b0cd2b7bc6c8db5"
|
||||||
|
dependencies = [
|
||||||
|
"bytes",
|
||||||
|
"memchr",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "concolor-clap"
|
name = "concolor-clap"
|
||||||
version = "0.0.6"
|
version = "0.0.6"
|
||||||
|
@ -572,15 +574,6 @@ dependencies = [
|
||||||
"termcolor",
|
"termcolor",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "float-cmp"
|
|
||||||
version = "0.9.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "98de4bbd547a563b716d8dfa9aad1cb19bfab00f4fa09a6a4ed21dbcf44ce9c4"
|
|
||||||
dependencies = [
|
|
||||||
"num-traits",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "fnv"
|
name = "fnv"
|
||||||
version = "1.0.7"
|
version = "1.0.7"
|
||||||
|
@ -610,6 +603,12 @@ version = "0.25.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f0a01e0497841a3b2db4f8afa483cce65f7e96a3498bd6c541734792aeac8fe7"
|
checksum = "f0a01e0497841a3b2db4f8afa483cce65f7e96a3498bd6c541734792aeac8fe7"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "glob"
|
||||||
|
version = "0.3.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "globset"
|
name = "globset"
|
||||||
version = "0.4.8"
|
version = "0.4.8"
|
||||||
|
@ -640,6 +639,12 @@ version = "1.7.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "62aca2aba2d62b4a7f5b33f3712cb1b0692779a56fb510499d5c0aa594daeaf3"
|
checksum = "62aca2aba2d62b4a7f5b33f3712cb1b0692779a56fb510499d5c0aa594daeaf3"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "hashbrown"
|
||||||
|
version = "0.11.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "heck"
|
name = "heck"
|
||||||
version = "0.3.3"
|
version = "0.3.3"
|
||||||
|
@ -679,6 +684,16 @@ version = "2.1.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
|
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]]
|
[[package]]
|
||||||
name = "ident_case"
|
name = "ident_case"
|
||||||
version = "1.0.1"
|
version = "1.0.1"
|
||||||
|
@ -703,6 +718,16 @@ dependencies = [
|
||||||
"winapi-util",
|
"winapi-util",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "indexmap"
|
||||||
|
version = "1.7.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "bc633605454125dec4b66843673f01c7df2b89479b32e0ed634e43a91cff62a5"
|
||||||
|
dependencies = [
|
||||||
|
"autocfg",
|
||||||
|
"hashbrown",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "itertools"
|
name = "itertools"
|
||||||
version = "0.10.1"
|
version = "0.10.1"
|
||||||
|
@ -996,11 +1021,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5c6ce811d0b2e103743eec01db1c50612221f173084ce2f7941053e94b6bb474"
|
checksum = "5c6ce811d0b2e103743eec01db1c50612221f173084ce2f7941053e94b6bb474"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"difflib",
|
"difflib",
|
||||||
"float-cmp",
|
|
||||||
"itertools",
|
"itertools",
|
||||||
"normalize-line-endings",
|
|
||||||
"predicates-core",
|
"predicates-core",
|
||||||
"regex",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1289,6 +1311,12 @@ dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "shlex"
|
||||||
|
version = "1.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "simdutf8"
|
name = "simdutf8"
|
||||||
version = "0.1.3"
|
version = "0.1.3"
|
||||||
|
@ -1440,12 +1468,47 @@ dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[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]]
|
[[package]]
|
||||||
name = "treeline"
|
name = "treeline"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a7f741b240f1a48843f9b8e0444fb55fb2a4ff67293b50a9179dfd5ea67f8d41"
|
checksum = "a7f741b240f1a48843f9b8e0444fb55fb2a4ff67293b50a9179dfd5ea67f8d41"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "trycmd"
|
||||||
|
version = "0.2.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3756168da9e15c2ba53478a9e14661162bd724cc45dc650d1009d80ad46f0cad"
|
||||||
|
dependencies = [
|
||||||
|
"concolor-control",
|
||||||
|
"difflib",
|
||||||
|
"glob",
|
||||||
|
"humantime",
|
||||||
|
"humantime-serde",
|
||||||
|
"normalize-line-endings",
|
||||||
|
"rayon",
|
||||||
|
"serde",
|
||||||
|
"shlex",
|
||||||
|
"tempfile",
|
||||||
|
"toml_edit",
|
||||||
|
"wait-timeout",
|
||||||
|
"walkdir",
|
||||||
|
"yansi",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "typed-arena"
|
name = "typed-arena"
|
||||||
version = "2.0.1"
|
version = "2.0.1"
|
||||||
|
@ -1475,7 +1538,6 @@ version = "1.2.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ahash",
|
"ahash",
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"assert_cmd",
|
|
||||||
"assert_fs",
|
"assert_fs",
|
||||||
"atty",
|
"atty",
|
||||||
"bstr",
|
"bstr",
|
||||||
|
@ -1497,12 +1559,12 @@ dependencies = [
|
||||||
"log",
|
"log",
|
||||||
"maplit",
|
"maplit",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"predicates",
|
|
||||||
"proc-exit",
|
"proc-exit",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"structopt",
|
"structopt",
|
||||||
"toml",
|
"toml",
|
||||||
|
"trycmd",
|
||||||
"typed-arena",
|
"typed-arena",
|
||||||
"typos",
|
"typos",
|
||||||
"typos-dict",
|
"typos-dict",
|
||||||
|
|
|
@ -94,8 +94,7 @@ maplit = "1.0"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
assert_fs = "1.0"
|
assert_fs = "1.0"
|
||||||
assert_cmd = "2.0"
|
trycmd = "0.2.2"
|
||||||
predicates = "2.0"
|
|
||||||
criterion = "0.3"
|
criterion = "0.3"
|
||||||
|
|
||||||
[profile.dev]
|
[profile.dev]
|
||||||
|
|
50
tests/cli.rs
50
tests/cli.rs
|
@ -1,50 +0,0 @@
|
||||||
use assert_cmd::Command;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
#[cfg(feature = "dict")]
|
|
||||||
fn test_stdin_success() {
|
|
||||||
let mut cmd = Command::cargo_bin("typos").unwrap();
|
|
||||||
cmd.arg("-").write_stdin("Hello world");
|
|
||||||
cmd.assert().success();
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
#[cfg(feature = "dict")]
|
|
||||||
fn test_stdin_failure() {
|
|
||||||
let mut cmd = Command::cargo_bin("typos").unwrap();
|
|
||||||
cmd.arg("-").write_stdin("Apropriate world");
|
|
||||||
cmd.assert().code(2);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
#[cfg(feature = "dict")]
|
|
||||||
fn test_stdin_correct() {
|
|
||||||
let mut cmd = Command::cargo_bin("typos").unwrap();
|
|
||||||
cmd.arg("-")
|
|
||||||
.arg("--write-changes")
|
|
||||||
.write_stdin("Apropriate world");
|
|
||||||
cmd.assert().success().stdout("Appropriate world");
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
#[cfg(feature = "dict")]
|
|
||||||
fn test_file_failure() {
|
|
||||||
let mut cmd = Command::cargo_bin("typos").unwrap();
|
|
||||||
cmd.arg("README.md");
|
|
||||||
cmd.assert().code(2);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
#[cfg(feature = "dict")]
|
|
||||||
fn test_relative_dir_failure() {
|
|
||||||
let mut cmd = Command::cargo_bin("typos").unwrap();
|
|
||||||
cmd.arg(".");
|
|
||||||
cmd.assert().code(2);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
#[cfg(feature = "dict")]
|
|
||||||
fn test_assumed_dir_failure() {
|
|
||||||
let mut cmd = Command::cargo_bin("typos").unwrap();
|
|
||||||
cmd.assert().code(2);
|
|
||||||
}
|
|
5
tests/cli_tests.rs
Normal file
5
tests/cli_tests.rs
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
#[test]
|
||||||
|
#[cfg(feature = "dict")]
|
||||||
|
fn cli_tests() {
|
||||||
|
trycmd::TestCases::new().case("tests/cmd/*.toml");
|
||||||
|
}
|
2
tests/cmd/assumed-dir-failure.toml
Normal file
2
tests/cmd/assumed-dir-failure.toml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
bin.name = "typos"
|
||||||
|
status.code = 2
|
3
tests/cmd/file-failure.toml
Normal file
3
tests/cmd/file-failure.toml
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
bin.name = "typos"
|
||||||
|
args = "README.md"
|
||||||
|
status.code = 2
|
3
tests/cmd/relative-dir-failure.toml
Normal file
3
tests/cmd/relative-dir-failure.toml
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
bin.name = "typos"
|
||||||
|
args = "."
|
||||||
|
status.code = 2
|
1
tests/cmd/stdin-correct.stdin
Normal file
1
tests/cmd/stdin-correct.stdin
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Apropriate world
|
1
tests/cmd/stdin-correct.stdout
Normal file
1
tests/cmd/stdin-correct.stdout
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Appropriate world
|
2
tests/cmd/stdin-correct.toml
Normal file
2
tests/cmd/stdin-correct.toml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
bin.name = "typos"
|
||||||
|
args = "--write-changes -"
|
1
tests/cmd/stdin-failure.stdin
Normal file
1
tests/cmd/stdin-failure.stdin
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Apropriate world
|
3
tests/cmd/stdin-failure.toml
Normal file
3
tests/cmd/stdin-failure.toml
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
bin.name = "typos"
|
||||||
|
args = "-"
|
||||||
|
status.code = 2
|
1
tests/cmd/stdin-success.stdin
Normal file
1
tests/cmd/stdin-success.stdin
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Hello world
|
2
tests/cmd/stdin-success.toml
Normal file
2
tests/cmd/stdin-success.toml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
bin.name = "typos"
|
||||||
|
args = "-"
|
Loading…
Reference in a new issue