From 0cdca6f49911581bc4b530256ad6f13dbf859554 Mon Sep 17 00:00:00 2001 From: Ben Brown <9870007+brownben@users.noreply.github.com> Date: Mon, 11 Nov 2024 15:21:36 +0000 Subject: [PATCH] output snapshot tests --- Cargo.lock | 50 +++++++++++++ Cargo.toml | 3 + tests/output.rs | 133 +++++++++++++++++++++++++++++++++++ tests/output/failed_test.py | 2 + tests/output/passing_test.py | 8 +++ tests/output/skipped_test.py | 6 ++ 6 files changed, 202 insertions(+) create mode 100644 tests/output.rs create mode 100644 tests/output/failed_test.py create mode 100644 tests/output/passing_test.py create mode 100644 tests/output/skipped_test.py diff --git a/Cargo.lock b/Cargo.lock index 9140e76..bc063a6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -326,6 +326,12 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "indoc" +version = "2.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b248f5224d1d606005e02c97f5aa4e88eeb230488bcc03bc9ca4d7991399f2b5" + [[package]] name = "instant" version = "0.1.13" @@ -578,6 +584,18 @@ dependencies = [ "crossbeam-utils", ] +[[package]] +name = "regex" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + [[package]] name = "regex-automata" version = "0.4.8" @@ -736,6 +754,15 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" +[[package]] +name = "strip-ansi-escapes" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55ff8ef943b384c414f54aefa961dd2bd853add74ec75e7ac74cf91dba62bcfa" +dependencies = [ + "vte", +] + [[package]] name = "strsim" version = "0.11.1" @@ -863,6 +890,26 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" +[[package]] +name = "vte" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f5022b5fbf9407086c180e9557be968742d839e68346af7792b8592489732197" +dependencies = [ + "utf8parse", + "vte_generate_state_changes", +] + +[[package]] +name = "vte_generate_state_changes" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e369bee1b05d510a7b4ed645f5faa90619e05437111783ea5848f28d97d3c2e" +dependencies = [ + "proc-macro2", + "quote", +] + [[package]] name = "wait-timeout" version = "0.2.0" @@ -1003,12 +1050,15 @@ dependencies = [ "clap", "ignore", "indicatif", + "indoc", "owo-colors", "pyo3-ffi", "rayon", + "regex", "ruff_python_parser", "serde", "serde_json", + "strip-ansi-escapes", "toml", "widestring", ] diff --git a/Cargo.toml b/Cargo.toml index 6943e69..39903e2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,6 +23,9 @@ widestring = "1.1.0" [dev-dependencies] assert_cmd = "2.0.16" +indoc = "2.0.5" +regex = "1.11.1" +strip-ansi-escapes = "0.2.0" [features] ci = [] diff --git a/tests/output.rs b/tests/output.rs new file mode 100644 index 0000000..722e75d --- /dev/null +++ b/tests/output.rs @@ -0,0 +1,133 @@ +use assert_cmd::Command; +use indoc::indoc; +use regex::Regex; + +// as the test order is non-deterministic, we only check the output when there is a single test + +#[test] +fn regular_output_passing() { + let output = Command::cargo_bin(env!("CARGO_PKG_NAME")) + .unwrap() + .arg("./tests/output/passing_test.py") + .output() + .unwrap(); + let (stdout, stderr) = (clean_output(output.stdout), clean_output(output.stderr)); + + assert!(output.status.success()); + assert_eq!(stdout, ""); + assert_eq!( + stderr, + indoc! {" + xc 🏃 (Python 3) + Found 1 tests from 1 files in