|
1 | 1 | //! Integration tests for rustfmt.
|
2 | 2 |
|
3 | 3 | 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}; |
6 | 6 | use std::process::Command;
|
7 | 7 |
|
8 | 8 | 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() {
|
200 | 200 | let (_stdout, stderr) = rustfmt(&args);
|
201 | 201 | assert!(!stderr.contains("error[internal]: left behind trailing whitespace"))
|
202 | 202 | }
|
| 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