Skip to content

Commit c256d74

Browse files
committed
Auto merge of #13929 - ehuss:squelch-unittest-warnings, r=weihanglo
Silence warnings running embedded unittests. The `util::toml::embedded::test_expand` unittests were printing warnings directly to stderr, circumventing the libtest override. They were displaying ``warning: `package.edition` is unspecified, defaulting to `2021` ``. That warning doesn't look particularly important for those tests, so this changes it to swallow the output. We may want to have some kind of utility function for generating a GlobalContext for testing purposes that does this, since this is a repeated pattern.
2 parents 0f685f6 + 369f5de commit c256d74

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/cargo/util/toml/embedded.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -265,12 +265,12 @@ mod test_expand {
265265

266266
macro_rules! si {
267267
($i:expr) => {{
268-
expand_manifest(
269-
$i,
270-
std::path::Path::new("/home/me/test.rs"),
271-
&GlobalContext::default().unwrap(),
272-
)
273-
.unwrap_or_else(|err| panic!("{}", err))
268+
let shell = crate::Shell::from_write(Box::new(Vec::new()));
269+
let cwd = std::env::current_dir().unwrap();
270+
let home = home::cargo_home_with_cwd(&cwd).unwrap();
271+
let gctx = GlobalContext::new(shell, cwd, home);
272+
expand_manifest($i, std::path::Path::new("/home/me/test.rs"), &gctx)
273+
.unwrap_or_else(|err| panic!("{}", err))
274274
}};
275275
}
276276

0 commit comments

Comments
 (0)