Skip to content

Commit 5481950

Browse files
committed
Add tests
1 parent 5c28d86 commit 5481950

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

tests/rustfmt/main.rs

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
//! Integration tests for rustfmt.
22
33
use std::env;
4-
use std::fs::remove_file;
5-
use std::path::Path;
4+
use std::fs::{read_to_string, remove_file};
5+
use std::path::{Path, PathBuf};
66
use std::process::Command;
77

88
use rustfmt_config_proc_macro::rustfmt_only_ci_test;
@@ -174,3 +174,30 @@ fn rustfmt_emits_error_on_line_overflow_true() {
174174
"line formatted, but exceeded maximum width (maximum: 100 (see `max_width` option)"
175175
))
176176
}
177+
178+
#[test]
179+
fn ignore_missing_sub_mod_false() {
180+
// Ensure that missing submodules cause module not found errors when trying to
181+
// resolve submodules with `skip_children=false` and `ignore_missing_submod=false`
182+
let args = [
183+
"--config=skip_children=false,ignore_missing_submod=false",
184+
"tests/source/issue-5609.rs",
185+
];
186+
let (_stdout, stderr) = rustfmt(&args);
187+
// Module resolution fails because we're unable to find `missing_submod.rs`
188+
assert!(stderr.contains("missing_submod.rs does not exist"))
189+
}
190+
191+
#[test]
192+
fn ignore_missing_sub_mod_true() {
193+
// Ensure that missing submodules don't cause module not found errors when trying to
194+
// resolve submodules with `skip_children=false` and `ignore_missing_submod=true`.
195+
let args = [
196+
"--emit=stdout",
197+
"--config=skip_children=false,ignore_missing_submod=true",
198+
"tests/source/issue-5609.rs",
199+
];
200+
let (stdout, _stderr) = rustfmt(&args);
201+
let target = read_to_string(PathBuf::from("tests/target/issue-5609.rs")).unwrap();
202+
assert!(stdout.ends_with(&target));
203+
}

0 commit comments

Comments
 (0)