diff --git a/.gitignore b/.gitignore index 68499bb..19326a6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ /target *report.json -/reports.json -/summary.md +*reports.json +*summary.md diff --git a/Cargo.lock b/Cargo.lock index 2f12e3c..b14b1b2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -60,6 +60,22 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "assert_cmd" +version = "2.0.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc1835b7f27878de8525dc71410b5a31cdcc5f230aed5ba5df968e09c201b23d" +dependencies = [ + "anstyle", + "bstr", + "doc-comment", + "libc", + "predicates", + "predicates-core", + "predicates-tree", + "wait-timeout", +] + [[package]] name = "autocfg" version = "1.3.0" @@ -78,6 +94,17 @@ version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" +[[package]] +name = "bstr" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40723b8fb387abc38f4f4a37c09073622e41dd12327033091ef8950659e6dc0c" +dependencies = [ + "memchr", + "regex-automata", + "serde", +] + [[package]] name = "cc" version = "1.1.5" @@ -123,6 +150,18 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0" +[[package]] +name = "difflib" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6184e33543162437515c2e2b48714794e37845ec9851711914eec9d308f6ebe8" + +[[package]] +name = "doc-comment" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" + [[package]] name = "env_filter" version = "0.1.2" @@ -246,6 +285,7 @@ dependencies = [ name = "lintestor" version = "0.1.2" dependencies = [ + "assert_cmd", "clap", "env_logger", "log", @@ -364,6 +404,33 @@ version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" +[[package]] +name = "predicates" +version = "3.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e9086cc7640c29a356d1a29fd134380bee9d8f79a17410aa76e7ad295f42c97" +dependencies = [ + "anstyle", + "difflib", + "predicates-core", +] + +[[package]] +name = "predicates-core" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae8177bee8e75d6846599c6b9ff679ed51e882816914eec639944d7c9aa11931" + +[[package]] +name = "predicates-tree" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41b740d195ed3166cd147c8047ec98db0e22ec019eb8eeb76d343b795304fb13" +dependencies = [ + "predicates-core", + "termtree", +] + [[package]] name = "proc-macro2" version = "1.0.86" @@ -508,6 +575,12 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "termtree" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" + [[package]] name = "toml" version = "0.8.19" @@ -560,6 +633,15 @@ version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" +[[package]] +name = "wait-timeout" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f200f5b12eb75f8c1ed65abd4b2db8a6e1b138a20de009dacee265a2498f3f6" +dependencies = [ + "libc", +] + [[package]] name = "winapi" version = "0.3.9" diff --git a/Cargo.toml b/Cargo.toml index 175f3c3..28b0203 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,6 +16,8 @@ openssl = { version = "0.10.66", features = ["vendored"] } toml = "0.8.19" env_logger = "0.11.5" log = "0.4.22" +[dev-dependencies] +assert_cmd = "2.0.16" [profile.release] strip = true diff --git a/tests/mod.rs b/tests/mod.rs new file mode 100644 index 0000000..15ab560 --- /dev/null +++ b/tests/mod.rs @@ -0,0 +1 @@ +pub mod tests; diff --git a/tests/test_files/distro_a/config.toml b/tests/test_files/distro_a/config.toml new file mode 100644 index 0000000..c209472 --- /dev/null +++ b/tests/test_files/distro_a/config.toml @@ -0,0 +1,5 @@ +enabled = true +testing_type = "locally" +# startup_script = "prerequisite.sh" +# stop_script = "prerequisite.sh" +skip_packages = ["docker"] diff --git a/tests/test_files/distro_a/test1/metadata.sh b/tests/test_files/distro_a/test1/metadata.sh new file mode 100644 index 0000000..93bd0ad --- /dev/null +++ b/tests/test_files/distro_a/test1/metadata.sh @@ -0,0 +1,4 @@ +PACKAGE_VERSION="1.1.4" +PACKAGE_PRETTY_NAME="Test-1" +PACKAGE_TYPE="testtype1" +PACKAGE_DESCRIPTION="just a test lol" diff --git a/tests/test_files/distro_a/test1/test.sh b/tests/test_files/distro_a/test1/test.sh new file mode 100644 index 0000000..749bf8a --- /dev/null +++ b/tests/test_files/distro_a/test1/test.sh @@ -0,0 +1,6 @@ +echo "This is an example dummy test script..." + +# Do your stuff here +sleep 0 + +return 0 diff --git a/tests/test_files/distro_a/test1/test2.sh b/tests/test_files/distro_a/test1/test2.sh new file mode 100644 index 0000000..cfec5b7 --- /dev/null +++ b/tests/test_files/distro_a/test1/test2.sh @@ -0,0 +1,6 @@ +echo "This is an example dummy test script but is the second one..." + +# Do your stuff here +sleep 0 + +return 0 diff --git a/tests/test_files/distro_a/test1/test3.sh b/tests/test_files/distro_a/test1/test3.sh new file mode 100644 index 0000000..b2a6cb7 --- /dev/null +++ b/tests/test_files/distro_a/test1/test3.sh @@ -0,0 +1,6 @@ +echo "This is an example dummy test script but is the third one..." + +# Do your stuff here +sleep 0 + +return 0 diff --git a/tests/test_files/distro_a/test2/metadata.sh b/tests/test_files/distro_a/test2/metadata.sh new file mode 100644 index 0000000..490b4b6 --- /dev/null +++ b/tests/test_files/distro_a/test2/metadata.sh @@ -0,0 +1,4 @@ +PACKAGE_VERSION="5.1.4" +PACKAGE_PRETTY_NAME="Test-2" +PACKAGE_TYPE="testtype2" +PACKAGE_DESCRIPTION="also trying out" diff --git a/tests/test_files/distro_a/test2/test.sh b/tests/test_files/distro_a/test2/test.sh new file mode 100644 index 0000000..83fe71d --- /dev/null +++ b/tests/test_files/distro_a/test2/test.sh @@ -0,0 +1,6 @@ +echo "This is another example dummy test script..." + +# Do your stuff here +sleep 0 + +return 0 diff --git a/tests/test_files/distro_a/test3-ill/test.sh b/tests/test_files/distro_a/test3-ill/test.sh new file mode 100644 index 0000000..c9e471e --- /dev/null +++ b/tests/test_files/distro_a/test3-ill/test.sh @@ -0,0 +1,6 @@ +echo "This is yet another example dummy test script..." + +# Do your stuff here +sleep 0 + +return 0 diff --git a/tests/test_files/distro_a/test3/metadata.sh b/tests/test_files/distro_a/test3/metadata.sh new file mode 100644 index 0000000..9d328c7 --- /dev/null +++ b/tests/test_files/distro_a/test3/metadata.sh @@ -0,0 +1,4 @@ +PACKAGE_VERSION="1.9.19-8" +PACKAGE_PRETTY_NAME="Test-3" +PACKAGE_TYPE="testtype3" +PACKAGE_DESCRIPTION="I failed you im sorry!!1" diff --git a/tests/test_files/distro_a/test3/test.sh b/tests/test_files/distro_a/test3/test.sh new file mode 100644 index 0000000..c9e471e --- /dev/null +++ b/tests/test_files/distro_a/test3/test.sh @@ -0,0 +1,6 @@ +echo "This is yet another example dummy test script..." + +# Do your stuff here +sleep 0 + +return 0 diff --git a/tests/test_files/distro_a/test3/test2.sh b/tests/test_files/distro_a/test3/test2.sh new file mode 100644 index 0000000..d2287ec --- /dev/null +++ b/tests/test_files/distro_a/test3/test2.sh @@ -0,0 +1,6 @@ +echo "This is yet another example dummy test script... 2" + +# Do your stuff here +sleep 0 + +return 0 diff --git a/tests/test_files/distro_b/config.toml b/tests/test_files/distro_b/config.toml new file mode 100644 index 0000000..c209472 --- /dev/null +++ b/tests/test_files/distro_b/config.toml @@ -0,0 +1,5 @@ +enabled = true +testing_type = "locally" +# startup_script = "prerequisite.sh" +# stop_script = "prerequisite.sh" +skip_packages = ["docker"] diff --git a/tests/test_files/distro_b/test1/metadata.sh b/tests/test_files/distro_b/test1/metadata.sh new file mode 100644 index 0000000..93bd0ad --- /dev/null +++ b/tests/test_files/distro_b/test1/metadata.sh @@ -0,0 +1,4 @@ +PACKAGE_VERSION="1.1.4" +PACKAGE_PRETTY_NAME="Test-1" +PACKAGE_TYPE="testtype1" +PACKAGE_DESCRIPTION="just a test lol" diff --git a/tests/test_files/distro_b/test1/test.sh b/tests/test_files/distro_b/test1/test.sh new file mode 100644 index 0000000..749bf8a --- /dev/null +++ b/tests/test_files/distro_b/test1/test.sh @@ -0,0 +1,6 @@ +echo "This is an example dummy test script..." + +# Do your stuff here +sleep 0 + +return 0 diff --git a/tests/test_files/distro_b/test1/test2.sh b/tests/test_files/distro_b/test1/test2.sh new file mode 100644 index 0000000..cfec5b7 --- /dev/null +++ b/tests/test_files/distro_b/test1/test2.sh @@ -0,0 +1,6 @@ +echo "This is an example dummy test script but is the second one..." + +# Do your stuff here +sleep 0 + +return 0 diff --git a/tests/test_files/distro_b/test1/test3.sh b/tests/test_files/distro_b/test1/test3.sh new file mode 100644 index 0000000..b2a6cb7 --- /dev/null +++ b/tests/test_files/distro_b/test1/test3.sh @@ -0,0 +1,6 @@ +echo "This is an example dummy test script but is the third one..." + +# Do your stuff here +sleep 0 + +return 0 diff --git a/tests/test_files/distro_b/test2/metadata.sh b/tests/test_files/distro_b/test2/metadata.sh new file mode 100644 index 0000000..490b4b6 --- /dev/null +++ b/tests/test_files/distro_b/test2/metadata.sh @@ -0,0 +1,4 @@ +PACKAGE_VERSION="5.1.4" +PACKAGE_PRETTY_NAME="Test-2" +PACKAGE_TYPE="testtype2" +PACKAGE_DESCRIPTION="also trying out" diff --git a/tests/test_files/distro_b/test2/test.sh b/tests/test_files/distro_b/test2/test.sh new file mode 100644 index 0000000..83fe71d --- /dev/null +++ b/tests/test_files/distro_b/test2/test.sh @@ -0,0 +1,6 @@ +echo "This is another example dummy test script..." + +# Do your stuff here +sleep 0 + +return 0 diff --git a/tests/test_files/distro_b/test4/metadata.sh b/tests/test_files/distro_b/test4/metadata.sh new file mode 100644 index 0000000..9d328c7 --- /dev/null +++ b/tests/test_files/distro_b/test4/metadata.sh @@ -0,0 +1,4 @@ +PACKAGE_VERSION="1.9.19-8" +PACKAGE_PRETTY_NAME="Test-3" +PACKAGE_TYPE="testtype3" +PACKAGE_DESCRIPTION="I failed you im sorry!!1" diff --git a/tests/test_files/distro_b/test4/test.sh b/tests/test_files/distro_b/test4/test.sh new file mode 100644 index 0000000..5919c6a --- /dev/null +++ b/tests/test_files/distro_b/test4/test.sh @@ -0,0 +1,6 @@ +echo "This is yet another example dummy test script..." + +# Do your stuff here +sleep 0 + +return 1 diff --git a/tests/test_files/distro_b/test4/test2.sh b/tests/test_files/distro_b/test4/test2.sh new file mode 100644 index 0000000..d2287ec --- /dev/null +++ b/tests/test_files/distro_b/test4/test2.sh @@ -0,0 +1,6 @@ +echo "This is yet another example dummy test script... 2" + +# Do your stuff here +sleep 0 + +return 0 diff --git a/tests/tests.rs b/tests/tests.rs new file mode 100644 index 0000000..ba5eb96 --- /dev/null +++ b/tests/tests.rs @@ -0,0 +1,20 @@ +use assert_cmd::Command; +use std::{ + env, + io::{self, Write}, +}; +#[test] +fn integration_test() { + let mut cmd = Command::cargo_bin(env!("CARGO_PKG_NAME")).unwrap(); + let output = cmd + .arg("-tas") + .arg("-D") + .arg("tests/test_files") + .env("RUST_LOG", "debug") + .output() + .expect("failed to execute process"); + io::stdout().write_all(&output.stdout).unwrap(); + io::stderr().write_all(&output.stderr).unwrap(); + // TODO: append contents of reports.json and summary.md to stdout + assert!(output.status.success()); +}