mirror of
https://github.com/roc-lang/roc.git
synced 2024-09-22 08:17:40 +03:00
Merge pull request #2520 from rtfeldman/2495-check-format-tests
Add tests for `roc format --check {{file}}`
This commit is contained in:
commit
da568965f8
@ -69,6 +69,17 @@ mod cli_run {
|
||||
assert_multiline_str_eq!(err, expected.into());
|
||||
}
|
||||
|
||||
fn check_format_check_as_expected(file: &Path, expects_success_exit_code: bool) {
|
||||
let flags = &["--check"];
|
||||
let out = run_roc(&[&["format", &file.to_str().unwrap()], &flags[..]].concat());
|
||||
|
||||
if expects_success_exit_code {
|
||||
assert!(out.status.success());
|
||||
} else {
|
||||
assert!(!out.status.success());
|
||||
}
|
||||
}
|
||||
|
||||
fn check_output_with_stdin(
|
||||
file: &Path,
|
||||
stdin: &[&str],
|
||||
@ -863,6 +874,16 @@ mod cli_run {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn format_check_good() {
|
||||
check_format_check_as_expected(&fixture_file("format", "Formatted.roc"), true);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn format_check_reformatting_needed() {
|
||||
check_format_check_as_expected(&fixture_file("format", "NotFormatted.roc"), false);
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
|
6
cli/tests/fixtures/format/Formatted.roc
vendored
Normal file
6
cli/tests/fixtures/format/Formatted.roc
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
app "formatted"
|
||||
packages { pf: "platform" } imports []
|
||||
provides [ main ] to pf
|
||||
|
||||
main : Str
|
||||
main = Dep1.value1 {}
|
6
cli/tests/fixtures/format/NotFormatted.roc
vendored
Normal file
6
cli/tests/fixtures/format/NotFormatted.roc
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
app "formatted"
|
||||
packages { pf: "platform" }
|
||||
provides [ main ] to pf
|
||||
|
||||
main : Str
|
||||
main = Dep1.value1 {}
|
Loading…
Reference in New Issue
Block a user