Skip to content

Commit

Permalink
chore: Update snapbox
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Feb 14, 2024
1 parent 30addea commit f222712
Show file tree
Hide file tree
Showing 264 changed files with 1,432 additions and 1,404 deletions.
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ sha1 = "0.10.6"
sha2 = "0.10.8"
shell-escape = "0.1.5"
supports-hyperlinks = "2.1.0"
snapbox = { version = "0.4.16", features = ["diff", "path"] }
snapbox = { version = "0.5.0", features = ["diff", "path"] }
tar = { version = "0.4.40", default-features = false }
tempfile = "3.9.0"
thiserror = "1.0.56"
Expand Down
21 changes: 2 additions & 19 deletions crates/cargo-test-support/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,25 +35,8 @@ macro_rules! t {
};
}

#[macro_export]
macro_rules! curr_dir {
() => {
$crate::_curr_dir(std::path::Path::new(file!()));
};
}

#[doc(hidden)]
pub fn _curr_dir(mut file_path: &'static Path) -> &'static Path {
if !file_path.exists() {
// HACK: Must be running in the rust-lang/rust workspace, adjust the paths accordingly.
let prefix = PathBuf::from("src").join("tools").join("cargo");
if let Ok(crate_relative) = file_path.strip_prefix(prefix) {
file_path = crate_relative
}
}
assert!(file_path.exists(), "{} does not exist", file_path.display());
file_path.parent().unwrap()
}
pub use snapbox::file;
pub use snapbox::path::current_dir;

#[track_caller]
pub fn panic_error(what: &str, err: impl Into<anyhow::Error>) -> ! {
Expand Down
6 changes: 3 additions & 3 deletions tests/testsuite/cargo/help/mod.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use cargo_test_support::curr_dir;
use cargo_test_support::prelude::*;
use cargo_test_support::file;

#[cargo_test]
fn case() {
snapbox::cmd::Command::cargo_ui()
.arg("--help")
.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"]);
}
6 changes: 3 additions & 3 deletions tests/testsuite/cargo/z_help/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use cargo_test_support::curr_dir;
use cargo_test_support::prelude::*;
use cargo_test_support::file;

#[cargo_test]
fn case() {
Expand All @@ -8,6 +8,6 @@ fn case() {
.args(["-Z", "help"])
.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"]);
}
12 changes: 6 additions & 6 deletions tests/testsuite/cargo_add/add_basic/mod.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
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() {
cargo_test_support::registry::init();
Expand All @@ -19,7 +19,7 @@ fn case() {
cargo_test_support::registry::Package::new("my-package", ver).publish();
}

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;

Expand All @@ -29,8 +29,8 @@ 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);
}
12 changes: 6 additions & 6 deletions tests/testsuite/cargo_add/add_multiple/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;

use cargo_test_support::curr_dir;
use cargo_test_support::file;
use cargo_test_support::::current_dir;

#[cargo_test]
fn case() {
Expand All @@ -21,7 +21,7 @@ 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;

Expand All @@ -31,8 +31,8 @@ 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);
}
12 changes: 6 additions & 6 deletions tests/testsuite/cargo_add/add_normalized_name_external/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;

use cargo_test_support::curr_dir;
use cargo_test_support::file;
use cargo_test_support::::current_dir;

#[cargo_test]
fn case() {
Expand All @@ -24,7 +24,7 @@ fn case() {
.feature("unstable", &[])
.publish();

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;

Expand All @@ -34,8 +34,8 @@ 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);
}
12 changes: 6 additions & 6 deletions tests/testsuite/cargo_add/add_toolchain/mod.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;

use cargo_test_support::curr_dir;
use cargo_test_support::file;
use cargo_test_support::::current_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;

Expand All @@ -16,8 +16,8 @@ fn case() {
.current_dir(cwd)
.assert()
.failure()
.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);
}
12 changes: 6 additions & 6 deletions tests/testsuite/cargo_add/build/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;

use cargo_test_support::curr_dir;
use cargo_test_support::file;
use cargo_test_support::::current_dir;

#[cargo_test]
fn case() {
Expand All @@ -21,7 +21,7 @@ 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;

Expand All @@ -31,8 +31,8 @@ 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);
}
14 changes: 6 additions & 8 deletions tests/testsuite/cargo_add/build_prefer_existing_version/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
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;

Expand All @@ -19,8 +21,7 @@ fn case() {
.publish();
}

let project =
Project::from_template("tests/testsuite/cargo_add/build_prefer_existing_version/in");
let project = Project::from_template(current_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;

Expand All @@ -30,11 +31,8 @@ fn case() {
.current_dir(cwd)
.assert()
.success()
.stdout_matches_path("tests/testsuite/cargo_add/build_prefer_existing_version/stdout.log")
.stderr_matches_path("tests/testsuite/cargo_add/build_prefer_existing_version/stderr.log");
.stdout_matches(file!["stdout.log"])
.stderr_matches(file!["stderr.log"]);

assert_ui().subset_matches(
"tests/testsuite/cargo_add/build_prefer_existing_version/out",
&project_root,
);
assert_ui().subset_matches(current_dir!().join("out"), &project_root);
}
12 changes: 6 additions & 6 deletions tests/testsuite/cargo_add/change_rename_target/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;

use cargo_test_support::curr_dir;
use cargo_test_support::file;
use cargo_test_support::::current_dir;

#[cargo_test]
fn case() {
Expand All @@ -21,7 +21,7 @@ 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;

Expand All @@ -31,8 +31,8 @@ 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);
}
12 changes: 6 additions & 6 deletions tests/testsuite/cargo_add/cyclic_features/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;

use cargo_test_support::curr_dir;
use cargo_test_support::file;
use cargo_test_support::::current_dir;

#[cargo_test]
fn case() {
Expand All @@ -13,7 +13,7 @@ fn case() {
.feature("feature-two", &["feature-one"])
.publish();

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;

Expand All @@ -23,8 +23,8 @@ 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);
}
12 changes: 6 additions & 6 deletions tests/testsuite/cargo_add/default_features/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use cargo_test_support::compare::assert_ui;
use cargo_test_support::prelude::*;
use cargo_test_support::Project;

use cargo_test_support::curr_dir;
use cargo_test_support::file;
use cargo_test_support::::current_dir;

#[cargo_test]
fn case() {
Expand All @@ -21,7 +21,7 @@ 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;

Expand All @@ -31,8 +31,8 @@ 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);
}
Loading

0 comments on commit f222712

Please sign in to comment.