|
1 | 1 | //! Tests for the `cargo metadata` command.
|
2 | 2 |
|
| 3 | +use cargo_test_support::install::cargo_home; |
| 4 | +use cargo_test_support::paths::CargoPathExt; |
3 | 5 | use cargo_test_support::registry::Package;
|
4 | 6 | use cargo_test_support::{basic_bin_manifest, basic_lib_manifest, main_file, project, rustc_host};
|
5 | 7 |
|
@@ -2343,8 +2345,27 @@ fn filter_platform() {
|
2343 | 2345 | .replace("$ALT_TRIPLE", alt_target)
|
2344 | 2346 | .replace("$HOST_TRIPLE", &rustc_host());
|
2345 | 2347 |
|
| 2348 | + // We're going to be checking that we don't download excessively, |
| 2349 | + // so we need to ensure that downloads will happen. |
| 2350 | + let clear = || { |
| 2351 | + cargo_home().join("registry/cache").rm_rf(); |
| 2352 | + cargo_home().join("registry/src").rm_rf(); |
| 2353 | + p.build_dir().rm_rf(); |
| 2354 | + }; |
| 2355 | + |
2346 | 2356 | // Normal metadata, no filtering, returns *everything*.
|
2347 | 2357 | p.cargo("metadata")
|
| 2358 | + .with_stderr_unordered( |
| 2359 | + "\ |
| 2360 | +[UPDATING] [..] |
| 2361 | +[WARNING] please specify `--format-version` flag explicitly to avoid compatibility problems |
| 2362 | +[DOWNLOADING] crates ... |
| 2363 | +[DOWNLOADED] normal-dep v0.0.1 [..] |
| 2364 | +[DOWNLOADED] host-dep v0.0.1 [..] |
| 2365 | +[DOWNLOADED] alt-dep v0.0.1 [..] |
| 2366 | +[DOWNLOADED] cfg-dep v0.0.1 [..] |
| 2367 | +", |
| 2368 | + ) |
2348 | 2369 | .with_json(
|
2349 | 2370 | &r#"
|
2350 | 2371 | {
|
@@ -2454,10 +2475,20 @@ fn filter_platform() {
|
2454 | 2475 | .replace("$FOO", &foo),
|
2455 | 2476 | )
|
2456 | 2477 | .run();
|
| 2478 | + clear(); |
2457 | 2479 |
|
2458 | 2480 | // Filter on alternate, removes cfg and host.
|
2459 | 2481 | p.cargo("metadata --filter-platform")
|
2460 | 2482 | .arg(alt_target)
|
| 2483 | + .with_stderr_unordered( |
| 2484 | + "\ |
| 2485 | +[WARNING] please specify `--format-version` flag explicitly to avoid compatibility problems |
| 2486 | +[DOWNLOADING] crates ... |
| 2487 | +[DOWNLOADED] normal-dep v0.0.1 [..] |
| 2488 | +[DOWNLOADED] host-dep v0.0.1 [..] |
| 2489 | +[DOWNLOADED] alt-dep v0.0.1 [..] |
| 2490 | +", |
| 2491 | + ) |
2461 | 2492 | .with_json(
|
2462 | 2493 | &r#"
|
2463 | 2494 | {
|
@@ -2526,10 +2557,19 @@ fn filter_platform() {
|
2526 | 2557 | .replace("$FOO", &foo),
|
2527 | 2558 | )
|
2528 | 2559 | .run();
|
| 2560 | + clear(); |
2529 | 2561 |
|
2530 | 2562 | // Filter on host, removes alt and cfg.
|
2531 | 2563 | p.cargo("metadata --filter-platform")
|
2532 | 2564 | .arg(rustc_host())
|
| 2565 | + .with_stderr_unordered( |
| 2566 | + "\ |
| 2567 | +[WARNING] please specify `--format-version` flag explicitly to avoid compatibility problems |
| 2568 | +[DOWNLOADING] crates ... |
| 2569 | +[DOWNLOADED] normal-dep v0.0.1 [..] |
| 2570 | +[DOWNLOADED] host-dep v0.0.1 [..] |
| 2571 | +", |
| 2572 | + ) |
2533 | 2573 | .with_json(
|
2534 | 2574 | &r#"
|
2535 | 2575 | {
|
@@ -2598,11 +2638,21 @@ fn filter_platform() {
|
2598 | 2638 | .replace("$FOO", &foo),
|
2599 | 2639 | )
|
2600 | 2640 | .run();
|
| 2641 | + clear(); |
2601 | 2642 |
|
2602 | 2643 | // Filter host with cfg, removes alt only
|
2603 | 2644 | p.cargo("metadata --filter-platform")
|
2604 | 2645 | .arg(rustc_host())
|
2605 | 2646 | .env("RUSTFLAGS", "--cfg=foobar")
|
| 2647 | + .with_stderr_unordered( |
| 2648 | + "\ |
| 2649 | +[WARNING] please specify `--format-version` flag explicitly to avoid compatibility problems |
| 2650 | +[DOWNLOADING] crates ... |
| 2651 | +[DOWNLOADED] normal-dep v0.0.1 [..] |
| 2652 | +[DOWNLOADED] host-dep v0.0.1 [..] |
| 2653 | +[DOWNLOADED] cfg-dep v0.0.1 [..] |
| 2654 | +", |
| 2655 | + ) |
2606 | 2656 | .with_json(
|
2607 | 2657 | &r#"
|
2608 | 2658 | {
|
|
0 commit comments