Skip to content

Commit 29f64b6

Browse files
authored
Merge pull request #5 from oli-obk/runtest
Test that ui tests actually work
2 parents 466b246 + 5d3b386 commit 29f64b6

File tree

13 files changed

+733
-0
lines changed

13 files changed

+733
-0
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ version = "0.1.1"
44
edition = "2021"
55
license = "MIT OR Apache-2.0"
66
description = "A test framework for testing rustc diagnostics output"
7+
rust-version = "1.63"
78

89
[lib]
910
test = true # we have unit tests

rust-toolchain.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[toolchain]
2+
channel = "1.63.0"
3+
components = [ "rustfmt", "clippy" ]
4+
profile = "minimal"

src/lib.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,32 @@ pub struct Config {
5555
pub quiet: bool,
5656
}
5757

58+
impl Default for Config {
59+
fn default() -> Self {
60+
Self {
61+
args: vec![],
62+
target: None,
63+
stderr_filters: vec![],
64+
stdout_filters: vec![],
65+
root_dir: PathBuf::new(),
66+
mode: Mode::Fail,
67+
program: PathBuf::from("rustc"),
68+
output_conflict_handling: OutputConflictHandling::Error,
69+
path_filter: vec![],
70+
dependencies_crate_manifest_path: None,
71+
dependency_builder: None,
72+
quiet: true,
73+
}
74+
}
75+
}
76+
77+
impl Config {
78+
pub fn stderr_filter(&mut self, pattern: &str, replacement: &'static str) {
79+
self.stderr_filters
80+
.push((Regex::new(pattern).unwrap(), replacement));
81+
}
82+
}
83+
5884
#[derive(Debug)]
5985
pub struct DependencyBuilder {
6086
pub program: PathBuf,

tests/integration.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#[test]
2+
fn integrations() {
3+
run("basic");
4+
}
5+
6+
fn run(name: &str) {
7+
let path = std::path::Path::new(file!()).parent().unwrap();
8+
9+
let mut cmd = std::process::Command::new(std::env::var_os("CARGO").unwrap());
10+
cmd.arg("test");
11+
12+
cmd.arg("--target-dir");
13+
cmd.arg(path.parent().unwrap().join("target"));
14+
15+
cmd.arg("--manifest-path");
16+
cmd.arg(format!("{}/integrations/{name}/Cargo.toml", path.display()));
17+
18+
assert!(cmd.status().unwrap().success());
19+
}

0 commit comments

Comments
 (0)