Skip to content

Commit d769cb5

Browse files
committed
test(toml): Clean up manifest expanding helper
1 parent f018624 commit d769cb5

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

src/cargo/util/toml/embedded.rs

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -272,21 +272,20 @@ mod test_expand {
272272

273273
use super::*;
274274

275-
macro_rules! si {
276-
($i:expr) => {{
277-
let shell = crate::Shell::from_write(Box::new(Vec::new()));
278-
let cwd = std::env::current_dir().unwrap();
279-
let home = home::cargo_home_with_cwd(&cwd).unwrap();
280-
let gctx = GlobalContext::new(shell, cwd, home);
281-
expand_manifest($i, std::path::Path::new("/home/me/test.rs"), &gctx)
282-
.unwrap_or_else(|err| panic!("{}", err))
283-
}};
275+
#[track_caller]
276+
fn expand(source: &str) -> String {
277+
let shell = crate::Shell::from_write(Box::new(Vec::new()));
278+
let cwd = std::env::current_dir().unwrap();
279+
let home = home::cargo_home_with_cwd(&cwd).unwrap();
280+
let gctx = GlobalContext::new(shell, cwd, home);
281+
expand_manifest(source, std::path::Path::new("/home/me/test.rs"), &gctx)
282+
.unwrap_or_else(|err| panic!("{}", err))
284283
}
285284

286285
#[test]
287286
fn test_default() {
288287
assert_data_eq!(
289-
si!(r#"fn main() {}"#),
288+
expand(r#"fn main() {}"#),
290289
str![[r#"
291290
[[bin]]
292291
name = "test-"
@@ -314,12 +313,14 @@ strip = true
314313
#[test]
315314
fn test_dependencies() {
316315
assert_data_eq!(
317-
si!(r#"---cargo
316+
expand(
317+
r#"---cargo
318318
[dependencies]
319319
time="0.1.25"
320320
---
321321
fn main() {}
322-
"#),
322+
"#
323+
),
323324
str![[r#"
324325
[[bin]]
325326
name = "test-"
@@ -350,12 +351,14 @@ strip = true
350351
#[test]
351352
fn test_no_infostring() {
352353
assert_data_eq!(
353-
si!(r#"---
354+
expand(
355+
r#"---
354356
[dependencies]
355357
time="0.1.25"
356358
---
357359
fn main() {}
358-
"#),
360+
"#
361+
),
359362
str![[r#"
360363
[[bin]]
361364
name = "test-"

0 commit comments

Comments
 (0)