Auto merge of #13864 - justahero:fix/cargo-contributor-ui-test-code, r=weihanglo

Update UI example code in contributor guide

This updates the UI example case code in paragraph ["Writing Tests"](https://doc.crates.io/contrib/tests/writing.html#ui-tests) of the Cargo Contributor Guide. The previous code snippet did not compile successfully anymore.
This commit is contained in:
bors 2024-05-06 16:29:05 +00:00
commit 85a4d7041f

View File

@ -207,14 +207,15 @@ mod <case>;
`tests/testsuite/<command>/<case>/mod.rs`:
```rust,ignore
use cargo_test_support::prelude::*;
use cargo_test_support::compare::assert_ui;
use cargo_test_support::current_dir;
use cargo_test_support::file;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;
use cargo_test_support::curr_dir;
#[cargo_test]
fn case() {
let project = Project::from_template(curr_dir!().join("in"));
let project = Project::from_template(current_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
@ -224,10 +225,10 @@ fn case() {
.current_dir(cwd)
.assert()
.success()
.stdout_matches_path(curr_dir!().join("stdout.log"))
.stderr_matches_path(curr_dir!().join("stderr.log"));
.stdout_matches(file!("stdout.log"))
.stderr_matches(file!("stderr.log"));
assert_ui().subset_matches(curr_dir!().join("out"), &project_root);
assert_ui().subset_matches(current_dir!().join("out"), &project_root);
}
```