mirror of
https://github.com/rust-lang/cargo.git
synced 2025-10-01 11:30:39 +00:00

By rewriting the tests, with rerast (https://github.com/google/rerast), to use the newly introduced "at" method. First I added the following temporary function to cargotest::support: pub fn project_foo() -> ProjectBuilder { project("foo") } Then I defined the following rewrite.rs: use cargotest::support::{ project, project_foo }; fn rule1(a: &'static str) { replace!(project("foo") => project_foo()); replace!(project(a) => project_foo().at(a)); } Then I ran rerast: cargo +nightly rerast --rules_file=rewrite.rs --force --targets tests --file tests/testsuite/main.rs Finally I searched and replaced the references to project_foo with argument-less project (a little awkardly on macOS with a git clean). find tests -type f -exec sed -i -e 's/project_foo/project/g' {} + git clean -d tests
44 lines
1.1 KiB
Rust
44 lines
1.1 KiB
Rust
//! this file tests that when the commands being run are shown
|
|
//! in the output, their arguments are quoted properly
|
|
//! so that the command can be run in a terminal
|
|
|
|
use cargotest::support::{
|
|
execs,
|
|
project,
|
|
};
|
|
use hamcrest::assert_that;
|
|
|
|
#[test]
|
|
fn features_are_quoted() {
|
|
let p = project()
|
|
.file(
|
|
"Cargo.toml",
|
|
r#"
|
|
[project]
|
|
name = "foo"
|
|
version = "0.1.0"
|
|
authors = ["mikeyhew@example.com"]
|
|
|
|
[features]
|
|
some_feature = []
|
|
default = ["some_feature"]
|
|
"#,
|
|
)
|
|
.file("src/main.rs", "fn main() {error}")
|
|
.build();
|
|
|
|
assert_that(
|
|
p.cargo("check -v")
|
|
.env("MSYSTEM", "1"),
|
|
execs()
|
|
.with_status(101)
|
|
.with_stderr_contains(
|
|
r#"[RUNNING] `rustc [..] --cfg 'feature="default"' --cfg 'feature="some_feature"' [..]`"#
|
|
).with_stderr_contains(
|
|
r#"
|
|
Caused by:
|
|
process didn't exit successfully: [..] --cfg 'feature="default"' --cfg 'feature="some_feature"' [..]"#
|
|
)
|
|
);
|
|
}
|