Skip to content

Commit d894026

Browse files
committed
Add ui tests and move hello world examples there
1 parent 5b64312 commit d894026

File tree

8 files changed

+1007
-90
lines changed

8 files changed

+1007
-90
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ formality-rust = { version = "0.1.0", path = "crates/formality-rust" }
2222
formality-types = { version = "0.1.0", path = "crates/formality-types" }
2323
formality-check = { version = "0.1.0", path = "crates/formality-check" }
2424
formality-prove = { version = "0.1.0", path = "crates/formality-prove" }
25+
ui_test = "0.12"
2526

2627
[workspace]
2728
members = [
@@ -32,3 +33,7 @@ members = [
3233
"crates/formality-rust",
3334
"crates/formality-prove",
3435
]
36+
37+
[[test]]
38+
name = "ui"
39+
harness = false

src/lib.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::sync::Arc;
1+
use std::{path::PathBuf, sync::Arc};
22

33
use clap::Parser;
44
use formality_check::check_all_crates;
@@ -12,6 +12,18 @@ struct Args {
1212
#[arg(long)]
1313
print_rust: bool,
1414

15+
#[arg(long, default_value = "")]
16+
error_format: String,
17+
18+
#[arg(long, default_value = "")]
19+
crate_type: String,
20+
21+
#[arg(long, default_value = "")]
22+
edition: String,
23+
24+
#[arg(long)]
25+
out_dir: Option<PathBuf>,
26+
1527
input_path: String,
1628
}
1729

tests/hello_world.rs

Lines changed: 0 additions & 51 deletions
This file was deleted.

tests/ui.rs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
use ui_test::clap::Parser;
2+
use ui_test::color_eyre::Result;
3+
use ui_test::*;
4+
5+
fn main() -> Result<()> {
6+
let mut config = Config::rustc("tests/ui");
7+
// Prevent ui_test from trying to query `formality` for the host platform name
8+
config.host = Some("non of ya bizniz".into());
9+
config.program.program = "target/debug/formality".into();
10+
config.mode = Mode::Fail {
11+
require_patterns: false,
12+
};
13+
14+
let args = Args::parse();
15+
let text = if args.quiet {
16+
status_emitter::Text::quiet()
17+
} else {
18+
status_emitter::Text::verbose()
19+
};
20+
if !args.check && std::env::var_os("GITHUB_ACTIONS").is_none() {
21+
config.output_conflict_handling = OutputConflictHandling::Bless;
22+
}
23+
24+
run_tests_generic(
25+
config,
26+
args,
27+
|path, args| {
28+
path.extension().is_some_and(|ext| ext == "🔬") && default_filter_by_arg(path, args)
29+
},
30+
default_per_file_config,
31+
(text, status_emitter::Gha::<true> { name: "ui".into() }),
32+
)
33+
}

tests/ui/hello_world.🔬

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//@check-pass
2+
[
3+
crate Foo {
4+
trait Foo<ty T> where [T: Bar<Self>, Self: Baz<>] {}
5+
6+
trait Bar<ty T> where [T: Baz<>] {}
7+
8+
trait Baz<> where [] {}
9+
10+
impl<> Baz<> for u32 where [] {}
11+
12+
impl<> Bar<u32> for u32 where [] {}
13+
impl<ty T> Bar<T> for () where [T: Baz<>] {}
14+
}
15+
]

tests/ui/hello_world_fail.stderr

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Error: check_trait(Foo)
2+
3+
Caused by:
4+
0: prove_where_clause_well_formed(!ty_2 : Bar < !ty_1 >)
5+
1: failed to prove {@ WellFormedTraitRef(Bar(!ty_2, !ty_1))} given {Bar(!ty_2, !ty_1)}, got {}

tests/ui/hello_world_fail.🔬

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[
2+
crate Foo {
3+
trait Foo<ty T> where [T: Bar<Self>] {}
4+
5+
trait Bar<ty T> where [T: Baz<>] {}
6+
7+
trait Baz<> where [] {}
8+
}
9+
]

0 commit comments

Comments
 (0)