|
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;
|
@@ -174,3 +174,30 @@ fn rustfmt_emits_error_on_line_overflow_true() {
|
174 | 174 | "line formatted, but exceeded maximum width (maximum: 100 (see `max_width` option)"
|
175 | 175 | ))
|
176 | 176 | }
|
| 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