Skip to content

Commit aa4cd26

Browse files
committed
Add tests
1 parent 2faae32 commit aa4cd26

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;
@@ -200,3 +200,30 @@ fn rustfmt_emits_error_when_control_brace_style_is_always_next_line() {
200200
let (_stdout, stderr) = rustfmt(&args);
201201
assert!(!stderr.contains("error[internal]: left behind trailing whitespace"))
202202
}
203+
204+
#[test]
205+
fn ignore_missing_sub_mod_false() {
206+
// Ensure that missing submodules cause module not found errors when trying to
207+
// resolve submodules with `skip_children=false` and `ignore_missing_submod=false`
208+
let args = [
209+
"--config=skip_children=false,ignore_missing_submod=false",
210+
"tests/source/issue-5609.rs",
211+
];
212+
let (_stdout, stderr) = rustfmt(&args);
213+
// Module resolution fails because we're unable to find `missing_submod.rs`
214+
assert!(stderr.contains("missing_submod.rs does not exist"))
215+
}
216+
217+
#[test]
218+
fn ignore_missing_sub_mod_true() {
219+
// Ensure that missing submodules don't cause module not found errors when trying to
220+
// resolve submodules with `skip_children=false` and `ignore_missing_submod=true`.
221+
let args = [
222+
"--emit=stdout",
223+
"--config=skip_children=false,ignore_missing_submod=true",
224+
"tests/source/issue-5609.rs",
225+
];
226+
let (stdout, _stderr) = rustfmt(&args);
227+
let target = read_to_string(PathBuf::from("tests/target/issue-5609.rs")).unwrap();
228+
assert!(stdout.ends_with(&target));
229+
}

0 commit comments

Comments
 (0)