|
| 1 | +use std::fs; |
| 2 | + |
1 | 3 | use cargo_test_support::basic_manifest;
|
| 4 | +use cargo_test_support::paths::cargo_home; |
2 | 5 | use cargo_test_support::prelude::*;
|
3 | 6 | use cargo_test_support::registry::Package;
|
4 | 7 | use cargo_test_support::str;
|
@@ -318,26 +321,47 @@ rustc = "non-existent-rustc"
|
318 | 321 | .file("script.rs", script)
|
319 | 322 | .build();
|
320 | 323 |
|
321 |
| - // Verify the config is bad |
| 324 | + // Verify that the config from current directory is used |
322 | 325 | p.cargo("-Zscript script.rs -NotAnArg")
|
323 | 326 | .masquerade_as_nightly_cargo(&["script"])
|
324 |
| - .with_status(101) |
325 |
| - .with_stderr_data(str![[r#" |
326 |
| -[ERROR] could not execute process `non-existent-rustc -vV` (never executed) |
327 |
| -
|
328 |
| -Caused by: |
329 |
| - [NOT_FOUND] |
| 327 | + .with_stdout_data(str![[r#" |
| 328 | +bin: [ROOT]/home/.cargo/target/[HASH]/debug/script[EXE] |
| 329 | +args: ["-NotAnArg"] |
330 | 330 |
|
331 | 331 | "#]])
|
332 | 332 | .run();
|
333 | 333 |
|
334 |
| - // Verify that the config isn't used |
| 334 | + // Verify that the config from parent directory is not used |
335 | 335 | p.cargo("-Zscript ../script/script.rs -NotAnArg")
|
336 | 336 | .masquerade_as_nightly_cargo(&["script"])
|
337 | 337 | .with_stdout_data(str![[r#"
|
338 | 338 | bin: [ROOT]/home/.cargo/target/[HASH]/debug/script[EXE]
|
339 | 339 | args: ["-NotAnArg"]
|
340 | 340 |
|
| 341 | +"#]]) |
| 342 | + .run(); |
| 343 | + |
| 344 | + // Write a global config.toml in the cargo home directory |
| 345 | + let cargo_home = cargo_home(); |
| 346 | + fs::write( |
| 347 | + &cargo_home.join("config.toml"), |
| 348 | + r#" |
| 349 | +[build] |
| 350 | +rustc = "non-existent-rustc" |
| 351 | +"#, |
| 352 | + ) |
| 353 | + .unwrap(); |
| 354 | + |
| 355 | + // Verify the global config is used |
| 356 | + p.cargo("-Zscript script.rs -NotAnArg") |
| 357 | + .masquerade_as_nightly_cargo(&["script"]) |
| 358 | + .with_status(101) |
| 359 | + .with_stderr_data(str![[r#" |
| 360 | +[ERROR] could not execute process `non-existent-rustc -vV` (never executed) |
| 361 | +
|
| 362 | +Caused by: |
| 363 | + [NOT_FOUND] |
| 364 | +
|
341 | 365 | "#]])
|
342 | 366 | .run();
|
343 | 367 | }
|
|
0 commit comments