Skip to content

Commit 570032b

Browse files
committed
Introduce a proper error handling framework
1 parent b3e64c2 commit 570032b

File tree

8 files changed

+471
-50
lines changed

8 files changed

+471
-50
lines changed

Cargo.lock

Lines changed: 194 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/compiletest.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ use colored::*;
22
use regex::Regex;
33
use std::env;
44
use std::path::PathBuf;
5-
use ui_test::{Config, Mode, OutputConflictHandling};
5+
use ui_test::{Config, Mode, OutputConflictHandling, color_eyre::Result};
66

77
fn miri_path() -> PathBuf {
88
PathBuf::from(option_env!("MIRI").unwrap_or(env!("CARGO_BIN_EXE_miri")))
99
}
1010

11-
fn run_tests(mode: Mode, path: &str, target: Option<String>) {
11+
fn run_tests(mode: Mode, path: &str, target: Option<String>) -> Result<()> {
1212
let in_rustc_test_suite = option_env!("RUSTC_STAGE").is_some();
1313

1414
// Add some flags we always want.
@@ -108,7 +108,7 @@ regexes! {
108108
"sys/[a-z]+/" => "sys/PLATFORM/",
109109
}
110110

111-
fn ui(mode: Mode, path: &str) {
111+
fn ui(mode: Mode, path: &str) -> Result<()> {
112112
let target = get_target();
113113

114114
let msg = format!(
@@ -117,20 +117,24 @@ fn ui(mode: Mode, path: &str) {
117117
);
118118
eprintln!("{}", msg.green().bold());
119119

120-
run_tests(mode, path, target);
120+
run_tests(mode, path, target)
121121
}
122122

123123
fn get_target() -> Option<String> {
124124
env::var("MIRI_TEST_TARGET").ok()
125125
}
126126

127-
fn main() {
127+
fn main() -> Result<()> {
128+
ui_test::color_eyre::install()?;
129+
128130
// Add a test env var to do environment communication tests.
129131
env::set_var("MIRI_ENV_VAR_TEST", "0");
130132
// Let the tests know where to store temp files (they might run for a different target, which can make this hard to find).
131133
env::set_var("MIRI_TEMP", env::temp_dir());
132134

133-
ui(Mode::Pass, "tests/pass");
134-
ui(Mode::Panic, "tests/panic");
135-
ui(Mode::Fail, "tests/fail");
135+
ui(Mode::Pass, "tests/pass")?;
136+
ui(Mode::Panic, "tests/panic")?;
137+
ui(Mode::Fail, "tests/fail")?;
138+
139+
Ok(())
136140
}

0 commit comments

Comments
 (0)