|
| 1 | +//! Tests for multiple build scripts feature. |
| 2 | +
|
| 3 | +use cargo_test_support::prelude::*; |
| 4 | +use cargo_test_support::project; |
| 5 | +use cargo_test_support::str; |
| 6 | + |
| 7 | +#[cargo_test] |
| 8 | +fn build_without_feature_enabled_aborts_with_error() { |
| 9 | + let p = project() |
| 10 | + .file( |
| 11 | + "Cargo.toml", |
| 12 | + r#" |
| 13 | + [package] |
| 14 | + name = "foo" |
| 15 | + version = "0.1.0" |
| 16 | + edition = "2024" |
| 17 | + build = ["build1.rs", "build2.rs"] |
| 18 | + "#, |
| 19 | + ) |
| 20 | + .file("src/main.rs", "fn main() {}") |
| 21 | + .file("build1.rs", "fn main() {}") |
| 22 | + .file("build2.rs", "fn main() {}") |
| 23 | + .build(); |
| 24 | + p.cargo("check") |
| 25 | + .masquerade_as_nightly_cargo(&["multiple-build-scripts"]) |
| 26 | + .with_status(101) |
| 27 | + .with_stderr_data(str![[r#" |
| 28 | +[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml` |
| 29 | +
|
| 30 | +Caused by: |
| 31 | + feature `multiple-build-scripts` is required |
| 32 | +
|
| 33 | + The package requires the Cargo feature called `multiple-build-scripts`, but that feature is not stabilized in this version of Cargo (1.89.0 (158dd3559 2025-06-11)). |
| 34 | + Consider adding `cargo-features = ["multiple-build-scripts"]` to the top of Cargo.toml (above the [package] table) to tell Cargo you are opting in to use this unstable feature. |
| 35 | + See https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#multiple-build-scripts for more information about the status of this feature. |
| 36 | +
|
| 37 | +"#]]) |
| 38 | + .run(); |
| 39 | +} |
| 40 | + |
| 41 | +#[cargo_test] |
| 42 | +fn empty_multiple_build_script_project() { |
| 43 | + let p = project() |
| 44 | + .file( |
| 45 | + "Cargo.toml", |
| 46 | + r#" |
| 47 | + cargo-features = ["multiple-build-scripts"] |
| 48 | +
|
| 49 | + [package] |
| 50 | + name = "foo" |
| 51 | + version = "0.1.0" |
| 52 | + edition = "2024" |
| 53 | + build = ["build1.rs", "build2.rs"] |
| 54 | + "#, |
| 55 | + ) |
| 56 | + .file("src/main.rs", "fn main() {}") |
| 57 | + .file("build1.rs", "fn main() {}") |
| 58 | + .file("build2.rs", "fn main() {}") |
| 59 | + .build(); |
| 60 | + p.cargo("check") |
| 61 | + .masquerade_as_nightly_cargo(&["multiple-build-scripts"]) |
| 62 | + .with_status(101) |
| 63 | + .with_stderr_data(str![[r#" |
| 64 | +[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml` |
| 65 | +
|
| 66 | +Caused by: |
| 67 | + multiple build scripts feature is not implemented yet! |
| 68 | +
|
| 69 | +"#]]) |
| 70 | + .run(); |
| 71 | +} |
| 72 | + |
| 73 | +#[cargo_test] |
| 74 | +fn multiple_build_scripts_metadata() { |
| 75 | + let p = project() |
| 76 | + .file( |
| 77 | + "Cargo.toml", |
| 78 | + r#" |
| 79 | + cargo-features = ["multiple-build-scripts"] |
| 80 | +
|
| 81 | + [package] |
| 82 | + name = "foo" |
| 83 | + version = "0.1.0" |
| 84 | + edition = "2024" |
| 85 | + build = ["build1.rs", "build2.rs"] |
| 86 | + "#, |
| 87 | + ) |
| 88 | + .file("src/main.rs", "fn main() {}") |
| 89 | + .file("build1.rs", "fn main() {}") |
| 90 | + .file("build2.rs", "fn main() {}") |
| 91 | + .build(); |
| 92 | + p.cargo("metadata --format-version=1") |
| 93 | + .masquerade_as_nightly_cargo(&["multiple-build-scripts"]) |
| 94 | + .with_status(101) |
| 95 | + .with_stderr_data(str![[r#" |
| 96 | +[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml` |
| 97 | +
|
| 98 | +Caused by: |
| 99 | + multiple build scripts feature is not implemented yet! |
| 100 | +
|
| 101 | +"#]]) |
| 102 | + .run(); |
| 103 | +} |
0 commit comments