diff options
author | Martin Fischer <martin@push-f.com> | 2021-11-21 12:23:09 +0100 |
---|---|---|
committer | Martin Fischer <martin@push-f.com> | 2021-11-21 19:52:57 +0100 |
commit | 23fcd4ef079ad2b4aed69b4f363cbb9e7102c4ed (patch) | |
tree | 2fbf27f77274df35b31504e9b6cde5ed0a53455c /src/lib.rs | |
parent | 57641e00d6ed1fd7689c3079abb10f67d5387143 (diff) |
add ui tests (inspired by trybuild)
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 35 |
1 files changed, 35 insertions, 0 deletions
@@ -448,3 +448,38 @@ fn path_segment_for_trait(sometrait: &ItemTrait) -> PathSegment { #[doc = include_str!("../tests/doctests.md")] #[cfg(doctest)] struct Doctests; + +#[test] +fn ui() { + use std::process::Command; + + for entry in std::fs::read_dir("ui-tests/src/bin").unwrap().flatten() { + if entry.path().extension().unwrap() == "rs" { + let output = Command::new("cargo") + .arg("check") + .arg("--quiet") + .arg("--bin") + .arg(entry.path().file_stem().unwrap()) + .current_dir("ui-tests") + .output() + .unwrap(); + let received_stderr = std::str::from_utf8(&output.stderr) + .unwrap() + .lines() + .filter(|l| !l.starts_with("error: could not compile")) + .collect::<Vec<_>>() + .join("\n"); + let expected_stderr = + std::fs::read_to_string(entry.path().with_extension("stderr")).unwrap_or_default(); + if received_stderr != expected_stderr { + println!( + "EXPECTED:\n{banner}\n{expected}{banner}\n\nACTUAL OUTPUT:\n{banner}\n{actual}{banner}", + banner = "-".repeat(30), + expected = expected_stderr, + actual = received_stderr + ); + panic!("failed"); + } + } + } +} |