mirror of
https://github.com/roc-lang/roc.git
synced 2024-09-19 06:40:20 +03:00
add test_fmt_examples
This commit is contained in:
parent
8b967f1ea8
commit
4fed812389
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -3375,6 +3375,7 @@ dependencies = [
|
||||
"roc_parse",
|
||||
"roc_region",
|
||||
"roc_test_utils",
|
||||
"walkdir",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -16,3 +16,4 @@ bumpalo = { version = "3.8.0", features = ["collections"] }
|
||||
pretty_assertions = "1.0.0"
|
||||
indoc = "1.0.3"
|
||||
roc_test_utils = { path = "../../test_utils" }
|
||||
walkdir = "2.3.2"
|
||||
|
@ -63,7 +63,6 @@ mod test_fmt {
|
||||
}
|
||||
Err(error) => panic!("Unexpected parse failure when parsing this for defs formatting:\n\n{:?}\n\nParse error was:\n\n{:?}\n\n", src, error)
|
||||
}
|
||||
|
||||
assert_multiline_str_eq!(expected, buf.as_str())
|
||||
}
|
||||
Err(error) => panic!("Unexpected parse failure when parsing this for module header formatting:\n\n{:?}\n\nParse error was:\n\n{:?}\n\n", src, error)
|
||||
@ -71,8 +70,6 @@ mod test_fmt {
|
||||
}
|
||||
|
||||
fn module_formats_to(input: &str, expected: &str) {
|
||||
let input = input.trim_end();
|
||||
|
||||
// First check that input formats to the expected version
|
||||
expect_format_module_helper(input, expected);
|
||||
|
||||
@ -2941,6 +2938,35 @@ mod test_fmt {
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
/// Test that everything under examples/ is formatted correctly
|
||||
fn test_fmt_examples() {
|
||||
let mut count = 0;
|
||||
let mut root = std::env::current_dir()
|
||||
.unwrap()
|
||||
.parent()
|
||||
.unwrap()
|
||||
.parent()
|
||||
.unwrap()
|
||||
.to_owned();
|
||||
root.push("examples");
|
||||
for entry in walkdir::WalkDir::new(&root) {
|
||||
let entry = entry.unwrap();
|
||||
let path = entry.path();
|
||||
if path.extension() == Some(&std::ffi::OsStr::new("roc")) {
|
||||
count += 1;
|
||||
let src = std::fs::read_to_string(path).unwrap();
|
||||
println!("{}", path.display());
|
||||
module_formats_same(&src);
|
||||
}
|
||||
}
|
||||
assert!(
|
||||
count > 0,
|
||||
"Expecting to find at least 1 .roc file to format under {}",
|
||||
root.display()
|
||||
);
|
||||
}
|
||||
|
||||
// this is a parse error atm
|
||||
// #[test]
|
||||
// fn multiline_apply() {
|
||||
|
Loading…
Reference in New Issue
Block a user