From 4b38a9e8c5aa43a389d0ec9d3f06ad3b368d1793 Mon Sep 17 00:00:00 2001 From: d1t2 Date: Thu, 27 Jun 2024 16:49:47 +0800 Subject: [PATCH] test: Migrate git to snapbox --- tests/testsuite/git.rs | 1115 +++++++++++++++++++++------------------- 1 file changed, 580 insertions(+), 535 deletions(-) diff --git a/tests/testsuite/git.rs b/tests/testsuite/git.rs index 624fc4260fa6..c9b9603cea62 100644 --- a/tests/testsuite/git.rs +++ b/tests/testsuite/git.rs @@ -1,7 +1,5 @@ //! Tests for git support. -#![allow(deprecated)] - use std::fs; use std::io::prelude::*; use std::net::{TcpListener, TcpStream}; @@ -13,9 +11,10 @@ use std::thread; use cargo_test_support::git::cargo_uses_gitoxide; use cargo_test_support::paths::{self, CargoPathExt}; +use cargo_test_support::prelude::IntoData; use cargo_test_support::registry::Package; use cargo_test_support::{basic_lib_manifest, basic_manifest, git, main_file, path2url, project}; -use cargo_test_support::{sleep_ms, t, Project}; +use cargo_test_support::{sleep_ms, str, t, Project}; #[cargo_test] fn cargo_compile_simple_git_dep() { @@ -58,26 +57,23 @@ fn cargo_compile_simple_git_dep() { ) .build(); - let git_root = git_project.root(); - project .cargo("build") - .with_stderr(&format!( - "[UPDATING] git repository `{}`\n\ - [LOCKING] 2 packages to latest compatible versions\n\ - [COMPILING] dep1 v0.5.0 ({}#[..])\n\ - [COMPILING] foo v0.5.0 ([CWD])\n\ - [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]\n", - path2url(&git_root), - path2url(&git_root), - )) + .with_stderr_data(str![[r#" +[UPDATING] git repository `[ROOTURL]/dep1` +[LOCKING] 2 packages to latest compatible versions +[COMPILING] dep1 v0.5.0 ([ROOTURL]/dep1#[..]) +[COMPILING] foo v0.5.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); assert!(project.bin("foo").is_file()); project .process(&project.bin("foo")) - .with_stdout("hello world\n") + .with_stdout_data("hello world\n") .run(); } @@ -130,26 +126,26 @@ fn cargo_compile_git_dep_branch() { ) .build(); - let git_root = git_project.root(); - project .cargo("build") - .with_stderr(&format!( - "[UPDATING] git repository `{}`\n\ - [LOCKING] 2 packages to latest compatible versions\n\ - [COMPILING] dep1 v0.5.0 ({}?branch=branchy#[..])\n\ - [COMPILING] foo v0.5.0 ([CWD])\n\ - [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]\n", - path2url(&git_root), - path2url(&git_root), - )) + .with_stderr_data(str![[r#" +[UPDATING] git repository `[ROOTURL]/dep1` +[LOCKING] 2 packages to latest compatible versions +[COMPILING] dep1 v0.5.0 ([ROOTURL]/dep1?branch=branchy#[..]) +[COMPILING] foo v0.5.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); assert!(project.bin("foo").is_file()); project .process(&project.bin("foo")) - .with_stdout("hello world\n") + .with_stdout_data(str![[r#" +hello world + +"#]]) .run(); } @@ -207,26 +203,26 @@ fn cargo_compile_git_dep_tag() { ) .build(); - let git_root = git_project.root(); - project .cargo("build") - .with_stderr(&format!( - "[UPDATING] git repository `{}`\n\ - [LOCKING] 2 packages to latest compatible versions\n\ - [COMPILING] dep1 v0.5.0 ({}?tag=v0.1.0#[..])\n\ - [COMPILING] foo v0.5.0 ([CWD])\n\ - [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]\n", - path2url(&git_root), - path2url(&git_root), - )) + .with_stderr_data(str![[r#" +[UPDATING] git repository `[ROOTURL]/dep1` +[LOCKING] 2 packages to latest compatible versions +[COMPILING] dep1 v0.5.0 ([ROOTURL]/dep1?tag=v0.1.0#[..]) +[COMPILING] foo v0.5.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); assert!(project.bin("foo").is_file()); project .process(&project.bin("foo")) - .with_stdout("hello world\n") + .with_stdout_data(str![[r#" +hello world + +"#]]) .run(); project.cargo("build").run(); @@ -278,19 +274,16 @@ fn cargo_compile_git_dep_pull_request() { ) .build(); - let git_root = git_project.root(); - project .cargo("build") - .with_stderr(&format!( - "[UPDATING] git repository `{}`\n\ - [LOCKING] 2 packages to latest compatible versions\n\ - [COMPILING] dep1 v0.5.0 ({}?rev=refs/pull/330/head#[..])\n\ - [COMPILING] foo v0.0.0 ([CWD])\n\ - [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]\n", - path2url(&git_root), - path2url(&git_root), - )) + .with_stderr_data(str![[r#" +[UPDATING] git repository `[ROOTURL]/dep1` +[LOCKING] 2 packages to latest compatible versions +[COMPILING] dep1 v0.5.0 ([ROOTURL]/dep1?rev=refs/pull/330/head#[..]) +[COMPILING] foo v0.0.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); assert!(project.bin("foo").is_file()); @@ -375,7 +368,12 @@ fn cargo_compile_with_nested_paths() { assert!(p.bin("foo").is_file()); - p.process(&p.bin("foo")).with_stdout("hello world\n").run(); + p.process(&p.bin("foo")) + .with_stdout_data(str![[r#" +hello world + +"#]]) + .run(); } #[cargo_test] @@ -440,7 +438,12 @@ fn cargo_compile_with_malformed_nested_paths() { assert!(p.bin("foo").is_file()); - p.process(&p.bin("foo")).with_stdout("hello world\n").run(); + p.process(&p.bin("foo")) + .with_stdout_data(str![[r#" +hello world + +"#]]) + .run(); } #[cargo_test] @@ -511,7 +514,10 @@ fn cargo_compile_with_meta_package() { assert!(p.bin("foo").is_file()); p.process(&p.bin("foo")) - .with_stdout("this is dep1 this is dep2\n") + .with_stdout_data(str![[r#" +this is dep1 this is dep2 + +"#]]) .run(); } @@ -550,10 +556,10 @@ fn cargo_compile_with_short_ssh_git() { p.cargo("check") .with_status(101) - .with_stdout("") - .with_stderr(&format!( + .with_stdout_data(str![]) + .with_stderr_data(&format!( "\ -[ERROR] failed to parse manifest at `[..]` +[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml` Caused by: invalid url `{}`: relative URL without a base @@ -596,37 +602,48 @@ fn recompilation() { // First time around we should compile both foo and bar p.cargo("check") - .with_stderr(&format!( - "[UPDATING] git repository `{}`\n\ - [LOCKING] 2 packages to latest compatible versions\n\ - [CHECKING] bar v0.5.0 ({}#[..])\n\ - [CHECKING] foo v0.5.0 ([CWD])\n\ - [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) \ - in [..]\n", - git_project.url(), - git_project.url(), - )) + .with_stderr_data(str![[r#" +[UPDATING] git repository `[ROOTURL]/bar` +[LOCKING] 2 packages to latest compatible versions +[CHECKING] bar v0.5.0 ([ROOTURL]/bar#[..]) +[CHECKING] foo v0.5.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); // Don't recompile the second time - p.cargo("check").with_stderr("[FINISHED] [..]").run(); + p.cargo("check") + .with_stderr_data(str![[r#" +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) + .run(); // Modify a file manually, shouldn't trigger a recompile git_project.change_file("src/bar.rs", r#"pub fn bar() { println!("hello!"); }"#); - p.cargo("check").with_stderr("[FINISHED] [..]").run(); + p.cargo("check") + .with_stderr_data(str![[r#" +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) + .run(); p.cargo("update") - .with_stderr(&format!( - "\ -[UPDATING] git repository `{}` + .with_stderr_data(str![[r#" +[UPDATING] git repository `[ROOTURL]/bar` [LOCKING] 0 packages to latest compatible versions -", - git_project.url() - )) + +"#]]) .run(); - p.cargo("check").with_stderr("[FINISHED] [..]").run(); + p.cargo("check") + .with_stderr_data(str![[r#" +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) + .run(); // Commit the changes and make sure we don't trigger a recompile because the // lock file says not to change @@ -635,39 +652,46 @@ fn recompilation() { git::commit(&repo); println!("compile after commit"); - p.cargo("check").with_stderr("[FINISHED] [..]").run(); + p.cargo("check") + .with_stderr_data(str![[r#" +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) + .run(); p.root().move_into_the_past(); // Update the dependency and carry on! p.cargo("update") - .with_stderr(&format!( - "\ -[UPDATING] git repository `{}` + .with_stderr_data(str![[r#" +[UPDATING] git repository `[ROOTURL]/bar` [LOCKING] 1 package to latest compatible version -[UPDATING] bar v0.5.0 ([..]) -> #[..] -", - git_project.url() - )) +[UPDATING] bar v0.5.0 ([ROOTURL]/bar#[..]) -> #[..] + +"#]]) .run(); println!("going for the last compile"); p.cargo("check") - .with_stderr(&format!( - "[CHECKING] bar v0.5.0 ({}#[..])\n\ - [CHECKING] foo v0.5.0 ([CWD])\n\ - [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) \ - in [..]\n", - git_project.url(), - )) + .with_stderr_data(str![[r#" +[CHECKING] bar v0.5.0 ([ROOTURL]/bar#[..]) +[CHECKING] foo v0.5.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); // Make sure clean only cleans one dep - p.cargo("clean -p foo").with_stderr("[REMOVED] [..]").run(); + p.cargo("clean -p foo") + .with_stderr_data(str![[r#" +[REMOVED] [FILE_NUM] files, [FILE_SIZE]B total + +"#]]) + .run(); p.cargo("check") - .with_stderr( - "[CHECKING] foo v0.5.0 ([CWD])\n\ - [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) \ - in [..]", - ) + .with_stderr_data(str![[r#" +[CHECKING] foo v0.5.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -745,17 +769,16 @@ fn update_with_shared_deps() { // First time around we should compile both foo and bar p.cargo("check") - .with_stderr(&format!( - "\ -[UPDATING] git repository `{git}` + .with_stderr_data(str![[r#" +[UPDATING] git repository `[ROOTURL]/bar` [LOCKING] 4 packages to latest compatible versions -[CHECKING] bar v0.5.0 ({git}#[..]) -[CHECKING] [..] v0.5.0 ([..]) -[CHECKING] [..] v0.5.0 ([..]) -[CHECKING] foo v0.5.0 ([CWD]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]\n", - git = git_project.url(), - )) +[CHECKING] bar v0.5.0 ([ROOTURL]/bar#[..]) +[CHECKING] [..] v0.5.0 ([ROOT]/foo/dep[..]) +[CHECKING] [..] v0.5.0 ([ROOT]/foo/dep[..]) +[CHECKING] foo v0.5.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); // Modify a file manually, and commit it @@ -770,28 +793,26 @@ fn update_with_shared_deps() { // By default, not transitive updates println!("dep1 update"); p.cargo("update dep1") - .with_stderr( - "\ -[UPDATING] git repository [..] + .with_stderr_data(str![[r#" +[UPDATING] git repository `[ROOTURL]/bar` [LOCKING] 1 package to latest compatible version -[UPDATING] bar v0.5.0 [..] -", - ) +[UPDATING] bar v0.5.0 ([ROOTURL]/bar#[..]) -> #[..] + +"#]]) .run(); // Don't do anything bad on a weird --precise argument println!("bar bad precise update"); p.cargo("update bar --precise 0.1.2") .with_status(101) - .with_stderr( - "\ -[UPDATING] git repository [..] -[ERROR] Unable to update [..] + .with_stderr_data(str![[r#" +[UPDATING] git repository `[ROOTURL]/bar` +[ERROR] Unable to update [ROOTURL]/bar#0.1.2 Caused by: revspec '0.1.2' not found; class=Reference (4); code=NotFound (-3) -", - ) + +"#]]) .run(); // Specifying a precise rev to the old rev shouldn't actually update @@ -799,48 +820,43 @@ Caused by: println!("bar precise update"); p.cargo("update bar --precise") .arg(&old_head.to_string()) - .with_stderr( - "\ -[UPDATING] bar v0.5.0 [..]", - ) + .with_stderr_data(str![[r#" +[UPDATING] bar v0.5.0 ([ROOTURL]/bar#[..]) -> #[..] + +"#]]) .run(); // Updating recursively should, however, update the repo. println!("dep1 recursive update"); p.cargo("update dep1 --recursive") - .with_stderr(&format!( - "\ -[UPDATING] git repository `{}` + .with_stderr_data(str![[r#" +[UPDATING] git repository `[ROOTURL]/bar` [LOCKING] 1 package to latest compatible version -[UPDATING] bar v0.5.0 ([..]) -> #[..] -", - git_project.url() - )) +[UPDATING] bar v0.5.0 ([ROOTURL]/bar#[..]) -> #[..] + +"#]]) .run(); // Make sure we still only compile one version of the git repo println!("build"); p.cargo("check") - .with_stderr(&format!( - "\ -[CHECKING] bar v0.5.0 ({git}#[..]) -[CHECKING] [..] v0.5.0 ([CWD][..]dep[..]) -[CHECKING] [..] v0.5.0 ([CWD][..]dep[..]) -[CHECKING] foo v0.5.0 ([CWD]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]\n", - git = git_project.url(), - )) + .with_stderr_data(str![[r#" +[CHECKING] bar v0.5.0 ([ROOTURL]/bar#[..]) +[CHECKING] [..] v0.5.0 ([ROOT]/foo/dep[..]) +[CHECKING] [..] v0.5.0 ([ROOT]/foo/dep[..]) +[CHECKING] foo v0.5.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); // We should be able to update transitive deps p.cargo("update bar") - .with_stderr(&format!( - "\ -[UPDATING] git repository `{}` + .with_stderr_data(str![[r#" +[UPDATING] git repository `[ROOTURL]/bar` [LOCKING] 0 packages to latest compatible versions -", - git_project.url() - )) + +"#]]) .run(); } @@ -884,15 +900,15 @@ fn dep_with_submodule() { project .cargo("check") - .with_stderr( - "\ -[UPDATING] git repository [..] -[UPDATING] git submodule `file://[..]/dep2` + .with_stderr_data(str![[r#" +[UPDATING] git repository `[ROOTURL]/dep1` +[UPDATING] git submodule `[ROOTURL]/dep2` [LOCKING] 2 packages to latest compatible versions -[CHECKING] dep1 [..] -[CHECKING] foo [..] -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]\n", - ) +[CHECKING] dep1 v0.5.0 ([ROOTURL]/dep1#[..]) +[CHECKING] foo v0.5.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -953,16 +969,16 @@ fn dep_with_relative_submodule() { project .cargo("check") - .with_stderr( - "\ -[UPDATING] git repository [..] -[UPDATING] git submodule `file://[..]/deployment` + .with_stderr_data(str![[r#" +[UPDATING] git repository `[ROOTURL]/base` +[UPDATING] git submodule `[ROOTURL]/deployment` [LOCKING] 3 packages to latest compatible versions -[CHECKING] deployment [..] -[CHECKING] base [..] -[CHECKING] foo [..] -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]\n", - ) +[CHECKING] deployment v0.5.0 ([ROOTURL]/base#[..]) +[CHECKING] base v0.5.0 ([ROOTURL]/base#[..]) +[CHECKING] foo v0.5.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -1020,29 +1036,27 @@ fn dep_with_bad_submodule() { ) .build(); - let expected = format!( - "\ -[UPDATING] git repository [..] -[UPDATING] git submodule `file://[..]/dep2` -[ERROR] failed to get `dep1` as a dependency of package `foo v0.5.0 [..]` + let expected = str![[r#" +[UPDATING] git repository `[ROOTURL]/dep1` +[UPDATING] git submodule `[ROOTURL]/dep2` +[ERROR] failed to get `dep1` as a dependency of package `foo v0.5.0 ([ROOT]/foo)` Caused by: failed to load source for dependency `dep1` Caused by: - Unable to update {} + Unable to update [ROOTURL]/dep1 Caused by: failed to update submodule `src` Caused by: - object not found - no match for id [..] -", - path2url(git_project.root()) - ); + object not found - no match for id ([..]); class=Odb (9); code=NotFound (-3) + +"#]]; p.cargo("check") - .with_stderr(expected) + .with_stderr_data(expected) .with_status(101) .run(); } @@ -1091,15 +1105,15 @@ fn dep_with_skipped_submodule() { .build(); foo.cargo("check") - .with_stderr( - "\ -[UPDATING] git repository `file://[..]/bar` -[SKIPPING] git submodule `file://[..]/qux` [..] + .with_stderr_data(str![[r#" +[UPDATING] git repository `[ROOTURL]/bar` +[SKIPPING] git submodule `[ROOTURL]/qux` due to update strategy in .gitmodules [LOCKING] 2 packages to latest compatible versions -[CHECKING] bar [..] -[CHECKING] foo [..] -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]\n", - ) +[CHECKING] bar v0.0.0 ([ROOTURL]/bar#[..]) +[CHECKING] foo v0.0.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -1159,13 +1173,12 @@ fn ambiguous_published_deps() { p.cargo("build").run(); p.cargo("run") - .with_stderr( - "\ -[WARNING] skipping duplicate package `bar` found at `[..]` -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] + .with_stderr_data(str![[r#" +[WARNING] skipping duplicate package `bar` found at `[ROOT]/home/.cargo/git/checkouts/dep-[HASH]/[..]` +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s [RUNNING] `target/debug/foo[EXE]` -", - ) + +"#]]) .run(); } @@ -1220,15 +1233,16 @@ fn two_deps_only_update_one() { println!("dep2 head sha: {}", git_repo_head_sha(&git2)); p.cargo("check") - .with_stderr( - "[UPDATING] git repository `[..]`\n\ - [UPDATING] git repository `[..]`\n\ - [LOCKING] 3 packages to latest compatible versions\n\ - [CHECKING] [..] v0.5.0 ([..])\n\ - [CHECKING] [..] v0.5.0 ([..])\n\ - [CHECKING] foo v0.5.0 ([CWD])\n\ - [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]\n", - ) + .with_stderr_data(str![[r#" +[UPDATING] git repository `[ROOTURL]/dep1` +[UPDATING] git repository `[ROOTURL]/dep2` +[LOCKING] 3 packages to latest compatible versions +[CHECKING] [..] v0.5.0 ([ROOTURL]/dep[..]) +[CHECKING] [..] v0.5.0 ([ROOTURL]/dep[..]) +[CHECKING] foo v0.5.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); git1.change_file("src/lib.rs", "pub fn foo() {}"); @@ -1238,14 +1252,12 @@ fn two_deps_only_update_one() { println!("dep1 head sha: {}", oid_to_short_sha(oid)); p.cargo("update dep1") - .with_stderr(&format!( - "\ -[UPDATING] git repository `{}` + .with_stderr_data(str![[r#" +[UPDATING] git repository `[ROOTURL]/dep1` [LOCKING] 1 package to latest compatible version -[UPDATING] dep1 v0.5.0 ([..]) -> #[..] -", - git1.url() - )) +[UPDATING] dep1 v0.5.0 ([ROOTURL]/dep1#[..]) -> #[..] + +"#]]) .run(); } @@ -1323,15 +1335,13 @@ fn stale_cached_version() { // Now build! foo.cargo("build") - .with_stderr(&format!( - "\ -[UPDATING] git repository `{bar}` -[COMPILING] bar v0.0.0 ({bar}#[..]) -[COMPILING] foo v0.0.0 ([CWD]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - bar = bar.url(), - )) + .with_stderr_data(str![[r#" +[UPDATING] git repository `[ROOTURL]/meta-dep` +[COMPILING] bar v0.0.0 ([ROOTURL]/meta-dep#[..]) +[COMPILING] foo v0.0.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); foo.process(&foo.bin("foo")).run(); } @@ -1382,17 +1392,20 @@ fn dep_with_changed_submodule() { println!("first run"); p.cargo("run") - .with_stderr( - "[UPDATING] git repository `[..]`\n\ - [UPDATING] git submodule `file://[..]/dep2`\n\ - [LOCKING] 2 packages to latest compatible versions\n\ - [COMPILING] dep1 v0.5.0 ([..])\n\ - [COMPILING] foo v0.5.0 ([..])\n\ - [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in \ - [..]\n\ - [RUNNING] `target/debug/foo[EXE]`\n", - ) - .with_stdout("project2\n") + .with_stderr_data(str![[r#" +[UPDATING] git repository `[ROOTURL]/dep1` +[UPDATING] git submodule `[ROOTURL]/dep2` +[LOCKING] 2 packages to latest compatible versions +[COMPILING] dep1 v0.5.0 ([ROOTURL]/dep1#[..]) +[COMPILING] foo v0.5.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s +[RUNNING] `target/debug/foo[EXE]` + +"#]]) + .with_stdout_data(str![[r#" +project2 + +"#]]) .run(); git_project.change_file( @@ -1427,28 +1440,29 @@ fn dep_with_changed_submodule() { // Update the dependency and carry on! println!("update"); p.cargo("update") - .with_stderr("") - .with_stderr(&format!( - "\ -[UPDATING] git repository `{}` -[UPDATING] git submodule `file://[..]/dep3` + .with_stdout_data(str![]) + .with_stderr_data(str![[r#" +[UPDATING] git repository `[ROOTURL]/dep1` +[UPDATING] git submodule `[ROOTURL]/dep3` [LOCKING] 1 package to latest compatible version -[UPDATING] dep1 v0.5.0 ([..]) -> #[..] -", - git_project.url() - )) +[UPDATING] dep1 v0.5.0 ([ROOTURL]/dep1#[..]) -> #[..] + +"#]]) .run(); println!("last run"); p.cargo("run") - .with_stderr( - "[COMPILING] dep1 v0.5.0 ([..])\n\ - [COMPILING] foo v0.5.0 ([..])\n\ - [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in \ - [..]\n\ - [RUNNING] `target/debug/foo[EXE]`\n", - ) - .with_stdout("project3\n") + .with_stderr_data(str![[r#" +[COMPILING] dep1 v0.5.0 ([ROOTURL]/dep1#[..]) +[COMPILING] foo v0.5.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s +[RUNNING] `target/debug/foo[EXE]` + +"#]]) + .with_stdout_data(str![[r#" +project3 + +"#]]) .run(); } @@ -1501,28 +1515,30 @@ fn dev_deps_with_testing() { // Generate a lock file which did not use `bar` to compile, but had to update // `bar` to generate the lock file p.cargo("check") - .with_stderr(&format!( - "\ -[UPDATING] git repository `{bar}` + .with_stderr_data(str![[r#" +[UPDATING] git repository `[ROOTURL]/bar` [LOCKING] 2 packages to latest compatible versions -[CHECKING] foo v0.5.0 ([CWD]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - bar = p2.url() - )) +[CHECKING] foo v0.5.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); // Make sure we use the previous resolution of `bar` instead of updating it // a second time. p.cargo("test") - .with_stderr( - "\ -[COMPILING] [..] v0.5.0 ([..]) -[COMPILING] [..] v0.5.0 ([..] -[FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [..] -[RUNNING] [..] (target/debug/deps/foo-[..][EXE])", - ) - .with_stdout_contains("test tests::foo ... ok") + .with_stderr_data(str![[r#" +[COMPILING] bar v0.5.0 ([ROOTURL]/bar#[..]) +[COMPILING] foo v0.5.0 ([ROOT]/foo) +[FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s +[RUNNING] unittests src/main.rs (target/debug/deps/foo-[HASH][EXE]) + +"#]]) + .with_stdout_data(str![[r#" +... +test tests::foo ... ok +... +"#]]) .run(); } @@ -1550,22 +1566,31 @@ fn git_build_cmd_freshness() { sleep_ms(1000); foo.cargo("check") - .with_stderr( - "\ -[COMPILING] foo v0.0.0 ([CWD]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - ) + .with_stderr_data(str![[r#" +[COMPILING] foo v0.0.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); // Smoke test to make sure it doesn't compile again println!("first pass"); - foo.cargo("check").with_stderr("[FINISHED] [..]").run(); + foo.cargo("check") + .with_stderr_data(str![[r#" +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) + .run(); // Modify an ignored file and make sure we don't rebuild println!("second pass"); foo.change_file("src/bar.rs", ""); - foo.cargo("check").with_stderr("[FINISHED] [..]").run(); + foo.cargo("check") + .with_stderr_data(str![[r#" +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) + .run(); } #[cargo_test] @@ -1609,15 +1634,13 @@ fn git_name_not_always_needed() { // Generate a lock file which did not use `bar` to compile, but had to update // `bar` to generate the lock file p.cargo("check") - .with_stderr(&format!( - "\ -[UPDATING] git repository `{bar}` + .with_stderr_data(str![[r#" +[UPDATING] git repository `[ROOTURL]/bar` [LOCKING] 2 packages to latest compatible versions -[CHECKING] foo v0.5.0 ([CWD]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - bar = p2.url() - )) +[CHECKING] foo v0.5.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -1653,16 +1676,14 @@ fn git_repo_changing_no_rebuild() { .build(); p1.root().move_into_the_past(); p1.cargo("check") - .with_stderr(&format!( - "\ -[UPDATING] git repository `{bar}` + .with_stderr_data(str![[r#" +[UPDATING] git repository `[ROOTURL]/bar` [LOCKING] 2 packages to latest compatible versions -[COMPILING] [..] -[CHECKING] [..] -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - bar = bar.url() - )) +[COMPILING] p1 v0.5.0 ([ROOT]/p1) +[CHECKING] bar v0.5.0 ([ROOTURL]/bar#[..]) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); // Make a commit to lock p2 to a different rev @@ -1692,21 +1713,24 @@ fn git_repo_changing_no_rebuild() { .file("src/main.rs", "fn main() {}") .build(); p2.cargo("check") - .with_stderr(&format!( - "\ -[UPDATING] git repository `{bar}` + .with_stderr_data(str![[r#" +[UPDATING] git repository `[ROOTURL]/bar` [LOCKING] 2 packages to latest compatible versions -[CHECKING] [..] -[CHECKING] [..] -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - bar = bar.url() - )) +[CHECKING] bar v0.5.0 ([ROOTURL]/bar#[..]) +[CHECKING] p2 v0.5.0 ([ROOT]/p2) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); // And now for the real test! Make sure that p1 doesn't get rebuilt // even though the git repo has changed. - p1.cargo("check").with_stderr("[FINISHED] [..]").run(); + p1.cargo("check") + .with_stderr_data(str![[r#" +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) + .run(); } #[cargo_test] @@ -1771,14 +1795,24 @@ fn git_dep_build_cmd() { p.cargo("build").run(); - p.process(&p.bin("foo")).with_stdout("0\n").run(); + p.process(&p.bin("foo")) + .with_stdout_data(str![[r#" +0 + +"#]]) + .run(); // Touching bar.rs.in should cause the `build` command to run again. p.change_file("bar/src/bar.rs.in", "pub fn gimme() -> i32 { 1 }"); p.cargo("build").run(); - p.process(&p.bin("foo")).with_stdout("1\n").run(); + p.process(&p.bin("foo")) + .with_stdout_data(str![[r#" +1 + +"#]]) + .run(); } #[cargo_test] @@ -1808,16 +1842,14 @@ fn fetch_downloads() { .file("src/main.rs", "fn main() {}") .build(); p.cargo("fetch") - .with_stderr(&format!( - "\ -[UPDATING] git repository `{url}` + .with_stderr_data(str![[r#" +[UPDATING] git repository `[ROOTURL]/bar` [LOCKING] 2 packages to latest compatible versions -", - url = bar.url() - )) + +"#]]) .run(); - p.cargo("fetch").with_stderr("").run(); + p.cargo("fetch").with_stderr_data(str![]).run(); } #[cargo_test] @@ -1856,16 +1888,15 @@ fn fetch_downloads_with_git2_first_then_with_gitoxide_and_vice_versa() { p.cargo("fetch") .arg(feature_configuration) .masquerade_as_nightly_cargo(&["unstable features must be available for -Z gitoxide"]) - .with_stderr(&format!( - "\ -[UPDATING] git repository `{url}` -[LOCKING] 2 packages to latest compatible versions", - url = bar.url() - )) + .with_stderr_data(str![[r#" +[UPDATING] git repository `[ROOTURL]/bar` +[LOCKING] 2 packages to latest compatible versions + +"#]]) .run(); Package::new("bar", "1.0.0").publish(); // trigger a crates-index change. - p.cargo("fetch").with_stderr("").run(); + p.cargo("fetch").with_stderr_data(str![]).run(); } #[cargo_test] @@ -1896,15 +1927,14 @@ fn warnings_in_git_dep() { .build(); p.cargo("check") - .with_stderr(&format!( - "[UPDATING] git repository `{}`\n\ - [LOCKING] 2 packages to latest compatible versions\n\ - [CHECKING] bar v0.5.0 ({}#[..])\n\ - [CHECKING] foo v0.5.0 ([CWD])\n\ - [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]\n", - bar.url(), - bar.url(), - )) + .with_stderr_data(str![[r#" +[UPDATING] git repository `[ROOTURL]/bar` +[LOCKING] 2 packages to latest compatible versions +[CHECKING] bar v0.5.0 ([ROOTURL]/bar#[..]) +[CHECKING] foo v0.5.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -1966,16 +1996,13 @@ fn update_ambiguous() { p.cargo("generate-lockfile").run(); p.cargo("update bar") .with_status(101) - .with_stderr( - "\ -[ERROR] There are multiple `bar` packages in your project, and the specification `bar` \ -is ambiguous. -Please re-run this command with one of the \ -following specifications: - bar@0.[..].0 - bar@0.[..].0 -", - ) + .with_stderr_data(str![[r#" +[ERROR] There are multiple `bar` packages in your project, and the specification `bar` is ambiguous. +Please re-run this command with one of the following specifications: + bar@0.5.0 + bar@0.6.0 + +"#]]) .run(); } @@ -2013,13 +2040,11 @@ fn update_one_dep_in_repo_with_many_deps() { p.cargo("generate-lockfile").run(); p.cargo("update bar") - .with_stderr(&format!( - "\ -[UPDATING] git repository `{}` + .with_stderr_data(str![[r#" +[UPDATING] git repository `[ROOTURL]/bar` [LOCKING] 0 packages to latest compatible versions -", - bar.url() - )) + +"#]]) .run(); } @@ -2091,19 +2116,16 @@ fn switch_deps_does_not_update_transitive() { .build(); p.cargo("check") - .with_stderr(&format!( - "\ -[UPDATING] git repository `{}` -[UPDATING] git repository `{}` + .with_stderr_data(str![[r#" +[UPDATING] git repository `[ROOTURL]/dep1` +[UPDATING] git repository `[ROOTURL]/transitive` [LOCKING] 3 packages to latest compatible versions -[CHECKING] transitive [..] -[CHECKING] dep [..] -[CHECKING] foo [..] -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - dep1.url(), - transitive.url() - )) +[CHECKING] transitive v0.5.0 ([ROOTURL]/transitive#[..]) +[CHECKING] dep v0.5.0 ([ROOTURL]/dep1#[..]) +[CHECKING] foo v0.5.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); // Update the dependency to point to the second repository, but this @@ -2125,17 +2147,15 @@ fn switch_deps_does_not_update_transitive() { ); p.cargo("check") - .with_stderr(&format!( - "\ -[UPDATING] git repository `{}` + .with_stderr_data(str![[r#" +[UPDATING] git repository `[ROOTURL]/dep2` [LOCKING] 1 package to latest compatible version -[ADDING] dep v0.5.0 ([..]) -[CHECKING] dep [..] -[CHECKING] foo [..] -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - dep2.url() - )) +[ADDING] dep v0.5.0 ([ROOTURL]/dep2#[..]) +[CHECKING] dep v0.5.0 ([ROOTURL]/dep2#[..]) +[CHECKING] foo v0.5.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -2246,16 +2266,15 @@ fn switch_sources() { .build(); p.cargo("check") - .with_stderr( - "\ -[UPDATING] git repository `file://[..]a1` + .with_stderr_data(str![[r#" +[UPDATING] git repository `[ROOTURL]/a1` [LOCKING] 3 packages to latest compatible versions -[CHECKING] a v0.5.0 ([..]a1#[..] -[CHECKING] b v0.5.0 ([..]) -[CHECKING] foo v0.5.0 ([..]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - ) +[CHECKING] a v0.5.0 ([ROOTURL]/a1#[..]) +[CHECKING] b v0.5.0 ([ROOT]/foo/b) +[CHECKING] foo v0.5.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); p.change_file( @@ -2275,17 +2294,16 @@ fn switch_sources() { ); p.cargo("check") - .with_stderr( - "\ -[UPDATING] git repository `file://[..]a2` + .with_stderr_data(str![[r#" +[UPDATING] git repository `[ROOTURL]/a2` [LOCKING] 1 package to latest compatible version -[ADDING] a v0.5.1 ([..]) -[CHECKING] a v0.5.1 ([..]a2#[..] -[CHECKING] b v0.5.0 ([..]) -[CHECKING] foo v0.5.0 ([..]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - ) +[ADDING] a v0.5.1 ([ROOTURL]/a2#[..]) +[CHECKING] a v0.5.1 ([ROOTURL]/a2#[..]) +[CHECKING] b v0.5.0 ([ROOT]/foo/b) +[CHECKING] foo v0.5.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -2410,15 +2428,14 @@ fn lints_are_suppressed() { .build(); p.cargo("check") - .with_stderr( - "\ -[UPDATING] git repository `[..]` + .with_stderr_data(str![[r#" +[UPDATING] git repository `[ROOTURL]/a` [LOCKING] 2 packages to latest compatible versions -[CHECKING] a v0.5.0 ([..]) -[CHECKING] foo v0.0.1 ([..]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - ) +[CHECKING] a v0.5.0 ([ROOTURL]/a#[..]) +[CHECKING] foo v0.0.1 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -2455,15 +2472,14 @@ fn denied_lints_are_allowed() { .build(); p.cargo("check") - .with_stderr( - "\ -[UPDATING] git repository `[..]` + .with_stderr_data(str![[r#" +[UPDATING] git repository `[ROOTURL]/a` [LOCKING] 2 packages to latest compatible versions -[CHECKING] a v0.5.0 ([..]) -[CHECKING] foo v0.0.1 ([..]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - ) +[CHECKING] a v0.5.0 ([ROOTURL]/a#[..]) +[CHECKING] foo v0.0.1 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -2597,26 +2613,24 @@ fn include_overrides_gitignore() { p.cargo("check").run(); p.change_file("ignored.txt", "Trigger rebuild."); p.cargo("check -v") - .with_stderr( - "\ -[DIRTY] foo v0.5.0 ([..]): the precalculated components changed -[COMPILING] foo v0.5.0 ([..]) -[RUNNING] `[..]build-script-build[..]` -[RUNNING] `rustc --crate-name foo --edition=2015 src/lib.rs [..]` -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - ) + .with_stderr_data(str![[r#" +[DIRTY] foo v0.5.0 ([ROOT]/foo): the precalculated components changed +[COMPILING] foo v0.5.0 ([ROOT]/foo) +[RUNNING] `[ROOT]/foo/target/debug/build/foo-[HASH]/build-script-build` +[RUNNING] `rustc --crate-name foo --edition=2015 src/lib.rs [..] +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); p.cargo("package --list --allow-dirty") - .with_stdout( - "\ + .with_stdout_data(str![[r#" .cargo_vcs_info.json Cargo.toml Cargo.toml.orig ignored.txt src/lib.rs -", - ) + +"#]]) .run(); } @@ -2677,31 +2691,26 @@ fn invalid_git_dependency_manifest() { ) .build(); - let git_root = git_project.root(); - project .cargo("check") .with_status(101) - .with_stderr(&format!( - "\ -[UPDATING] git repository `{}` + .with_stderr_data(str![[r#" +[UPDATING] git repository `[ROOTURL]/dep1` [ERROR] duplicate key `categories` in table `package` - --> [..]/Cargo.toml:9:21 + --> ../home/.cargo/git/checkouts/dep1-[HASH]/[..]/Cargo.toml:9:21 | -9 | categories = [\"algorithms\"] +9 | categories = ["algorithms"] | ^ | -[ERROR] failed to get `dep1` as a dependency of package `foo v0.5.0 ([..])` +[ERROR] failed to get `dep1` as a dependency of package `foo v0.5.0 ([ROOT]/foo)` Caused by: failed to load source for dependency `dep1` Caused by: - Unable to update {} -", - path2url(&git_root), - path2url(&git_root), - )) + Unable to update [ROOTURL]/dep1 + +"#]]) .run(); } @@ -2770,14 +2779,24 @@ fn failed_submodule_checkout() { project .cargo("check") .with_status(101) - .with_stderr_contains(" failed to update submodule `src`") - .with_stderr_contains(" failed to update submodule `bar`") + .with_stderr_data(str![[r#" +... + failed to update submodule `src` +... + failed to update submodule `bar` +... +"#]]) .run(); project .cargo("check") .with_status(101) - .with_stderr_contains(" failed to update submodule `src`") - .with_stderr_contains(" failed to update submodule `bar`") + .with_stderr_data(str![[r#" +... + failed to update submodule `src` +... + failed to update submodule `bar` +... +"#]]) .run(); done.store(true, Ordering::SeqCst); @@ -2821,23 +2840,24 @@ fn use_the_cli() { ) .build(); - let stderr = "\ -[UPDATING] git repository `[..]` -[RUNNING] `git fetch [..]` -From [..] - * [new ref] [..] -> origin/HEAD[..] -[LOCKING] [..] -[CHECKING] dep1 [..] -[RUNNING] `rustc [..]` -[CHECKING] foo [..] -[RUNNING] `rustc [..]` -[FINISHED] [..] -"; + let stderr = str![[r#" +[UPDATING] git repository `[ROOTURL]/dep1` +[RUNNING] `git fetch --verbose --force --update-head-ok '[ROOTURL]/dep1' '+HEAD:refs/remotes/origin/HEAD'` +From [ROOTURL]/dep1 + * [new ref] HEAD -> origin/HEAD +[LOCKING] 2 packages to latest compatible versions +[CHECKING] dep1 v0.5.0 ([ROOTURL]/dep1#[..]) +[RUNNING] `rustc --crate-name dep1 [..]` +[CHECKING] foo v0.5.0 ([ROOT]/foo) +[RUNNING] `rustc --crate-name foo [..]` +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]; project .cargo("check -v") .env("LC_ALL", "C") - .with_stderr(stderr) + .with_stderr_data(stderr) .run(); assert!(paths::home().join(".cargo/git/CACHEDIR.TAG").is_file()); } @@ -2929,7 +2949,12 @@ fn git_with_cli_force() { ) .build(); p.cargo("build").run(); - p.rename_run("foo", "foo1").with_stdout("one").run(); + p.rename_run("foo", "foo1") + .with_stdout_data(str![[r#" +one + +"#]]) + .run(); // commit --amend a change that will require a force fetch. let repo = git2::Repository::open(&git_project.root()).unwrap(); @@ -2949,7 +2974,12 @@ fn git_with_cli_force() { // Perform the fetch. p.cargo("update").run(); p.cargo("build").run(); - p.rename_run("foo", "foo2").with_stdout("two").run(); + p.rename_run("foo", "foo2") + .with_stdout_data(str![[r#" +two + +"#]]) + .run(); } #[cargo_test(requires_git)] @@ -3017,17 +3047,16 @@ fn dirty_submodule() { git_project .cargo("package --no-verify") .with_status(101) - .with_stderr( - "\ -[WARNING] manifest has no [..] -See [..] + .with_stderr_data(str![[r#" +[WARNING] manifest has no description, license, license-file, documentation, homepage or repository. +See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info. [ERROR] 1 files in the working directory contain changes that were not yet committed into git: .gitmodules -to proceed despite [..] -", - ) +to proceed despite this and include the uncommitted changes, pass the `--allow-dirty` flag + +"#]]) .run(); git::commit(&repo); @@ -3038,17 +3067,16 @@ to proceed despite [..] git_project .cargo("package --no-verify") .with_status(101) - .with_stderr( - "\ -[WARNING] manifest has no [..] -See [..] + .with_stderr_data(str![[r#" +[WARNING] manifest has no description, license, license-file, documentation, homepage or repository. +See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info. [ERROR] 1 files in the working directory contain changes that were not yet committed into git: src/lib.rs -to proceed despite [..] -", - ) +to proceed despite this and include the uncommitted changes, pass the `--allow-dirty` flag + +"#]]) .run(); // Commit the change. let sub_repo = git2::Repository::open(git_project.root().join("src")).unwrap(); @@ -3065,17 +3093,16 @@ to proceed despite [..] git_project .cargo("package --no-verify") .with_status(101) - .with_stderr( - "\ -[WARNING] manifest has no [..] -See [..] + .with_stderr_data(str![[r#" +[WARNING] manifest has no description, license, license-file, documentation, homepage or repository. +See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info. [ERROR] 1 files in the working directory contain changes that were not yet committed into git: src/.gitmodules -to proceed despite [..] -", - ) +to proceed despite this and include the uncommitted changes, pass the `--allow-dirty` flag + +"#]]) .run(); // Commit the submodule addition. @@ -3088,17 +3115,16 @@ to proceed despite [..] git_project .cargo("package --no-verify") .with_status(101) - .with_stderr( - "\ -[WARNING] manifest has no [..] -See [..] + .with_stderr_data(str![[r#" +[WARNING] manifest has no description, license, license-file, documentation, homepage or repository. +See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info. [ERROR] 1 files in the working directory contain changes that were not yet committed into git: src/bar/new_file.rs -to proceed despite [..] -", - ) +to proceed despite this and include the uncommitted changes, pass the `--allow-dirty` flag + +"#]]) .run(); // And commit the change. let sub_sub_repo = git2::Repository::open(git_project.root().join("src/bar")).unwrap(); @@ -3153,14 +3179,14 @@ fn default_not_master() { project .cargo("check") - .with_stderr( - "\ -[UPDATING] git repository `[..]` + .with_stderr_data(str![[r#" +[UPDATING] git repository `[ROOTURL]/dep1` [LOCKING] 2 packages to latest compatible versions -[CHECKING] dep1 v0.5.0 ([..]) -[CHECKING] foo v0.5.0 ([..]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]", - ) +[CHECKING] dep1 v0.5.0 ([ROOTURL]/dep1#[..]) +[CHECKING] foo v0.5.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -3218,13 +3244,12 @@ dependencies = [ ); project .cargo("check") - .with_stderr( - "\ + .with_stderr_data(str![[r#" [LOCKING] 1 package to latest compatible version -[ADDING] dep1 v0.5.0 ([..]) -[FINISHED] [..] -", - ) +[ADDING] dep1 v0.5.0 ([ROOTURL]/dep1?branch=master#[..]) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -3336,18 +3361,17 @@ fn two_dep_forms() { // the two local deps. project .cargo("check") - .with_stderr( - "\ -[UPDATING] [..] -[UPDATING] [..] -[LOCKING] [..] -[CHECKING] [..] -[CHECKING] [..] -[CHECKING] [..] -[CHECKING] [..] -[FINISHED] [..] -", - ) + .with_stderr_data(str![[r#" +[UPDATING] git repository `[ROOTURL]/dep1` +[UPDATING] git repository `[ROOTURL]/dep1` +[LOCKING] 4 packages to latest compatible versions +[CHECKING] dep1 v0.5.0 ([ROOTURL]/dep1#[..]) +[CHECKING] dep1 v0.5.0 ([ROOTURL]/dep1?branch=master#[..]) +[CHECKING] a v0.5.0 ([ROOT]/foo/a) +[CHECKING] foo v0.5.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -3518,8 +3542,10 @@ fn metadata_master_consistency() { .replace("__BAR_HASH__", &bar_hash) }; - let bar_source = format!("git+{}?branch=master", git_project.url()); - p.cargo("metadata").with_json(&metadata(&bar_source)).run(); + let bar_source = "git+[ROOTURL]/bar?branch=master"; + p.cargo("metadata") + .with_stdout_data(&metadata(&bar_source).json()) + .run(); // Conversely, remove branch="master" from Cargo.toml, but use a new Cargo.lock that has ?branch=master. let p = project() @@ -3562,8 +3588,10 @@ fn metadata_master_consistency() { .build(); // No ?branch=master! - let bar_source = format!("git+{}", git_project.url()); - p.cargo("metadata").with_json(&metadata(&bar_source)).run(); + let bar_source = "git+[ROOTURL]/bar"; + p.cargo("metadata") + .with_stdout_data(&metadata(&bar_source).json()) + .run(); } #[cargo_test] @@ -3599,7 +3627,12 @@ fn git_with_force_push() { .build(); // Download the original and make sure it is OK. p.cargo("build").run(); - p.rename_run("foo", "foo1").with_stdout("one").run(); + p.rename_run("foo", "foo1") + .with_stdout_data(str![[r#" +one + +"#]]) + .run(); let find_head = || t!(t!(repo.head()).peel_to_commit()); @@ -3621,39 +3654,54 @@ fn git_with_force_push() { let mut rename_annoyance = 1; - let mut verify = |text: &str| { + let mut verify = |text| { // Perform the fetch. p.cargo("update").run(); p.cargo("build").run(); rename_annoyance += 1; p.rename_run("foo", &format!("foo{}", rename_annoyance)) - .with_stdout(text) + .with_stdout_data(text) .run(); }; amend_commit("two"); - verify("two"); + verify(str![[r#" +two + +"#]]); // Try with a rev. let head1 = find_head().id().to_string(); let extra = format!(", rev = \"{}\"", head1); p.change_file("Cargo.toml", &manifest(&extra)); - verify("two"); + verify(str![[r#" +two + +"#]]); amend_commit("three"); let head2 = find_head().id().to_string(); assert_ne!(&head1, &head2); let extra = format!(", rev = \"{}\"", head2); p.change_file("Cargo.toml", &manifest(&extra)); - verify("three"); + verify(str![[r#" +three + +"#]]); // Try with a tag. git::tag(&repo, "my-tag"); p.change_file("Cargo.toml", &manifest(", tag = \"my-tag\"")); - verify("three"); + verify(str![[r#" +three + +"#]]); amend_commit("tag-three"); let head = t!(t!(repo.head()).peel(git2::ObjectType::Commit)); t!(repo.tag("my-tag", &head, &t!(repo.signature()), "move tag", true)); - verify("tag-three"); + verify(str![[r#" +tag-three + +"#]]); // Try with a branch. let br = t!(repo.branch("awesome-stuff", &find_head(), false)); @@ -3663,9 +3711,15 @@ fn git_with_force_push() { git::add(&repo); git::commit(&repo); p.change_file("Cargo.toml", &manifest(", branch = \"awesome-stuff\"")); - verify("awesome-three"); + verify(str![[r#" +awesome-three + +"#]]); amend_commit("awesome-four"); - verify("awesome-four"); + verify(str![[r#" +awesome-four + +"#]]); } #[cargo_test] @@ -3774,7 +3828,7 @@ fn different_user_relative_submodules() { .file("Cargo.toml", &basic_lib_manifest("dep1")) .file("src/lib.rs", "") }); - let user2_git_project2 = git::new("user2/dep2", |project| { + let _user2_git_project2 = git::new("user2/dep2", |project| { project .file("Cargo.toml", &basic_lib_manifest("dep1")) .file("src/lib.rs", "") @@ -3811,21 +3865,16 @@ fn different_user_relative_submodules() { project .cargo("build") - .with_stderr(&format!( - "\ -[UPDATING] git repository `{}` -[UPDATING] git submodule `{}` -[UPDATING] git submodule `{}` + .with_stderr_data(str![[r#" +[UPDATING] git repository `[ROOTURL]/user1/dep1` +[UPDATING] git submodule `[ROOTURL]/user2/dep1` +[UPDATING] git submodule `[ROOTURL]/user2/dep2` [LOCKING] 2 packages to latest compatible versions -[COMPILING] dep1 v0.5.0 ({}#[..]) -[COMPILING] foo v0.5.0 ([CWD]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - path2url(&user1_git_project.root()), - path2url(&user2_git_project.root()), - path2url(&user2_git_project2.root()), - path2url(&user1_git_project.root()), - )) +[COMPILING] dep1 v0.5.0 ([ROOTURL]/user1/dep1#[..]) +[COMPILING] foo v0.5.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); assert!(project.bin("foo").is_file()); @@ -3870,26 +3919,24 @@ fn git_worktree_with_original_repo_renamed() { project .cargo("package --list") .cwd(&new) - .with_stdout( - "\ + .with_stdout_data(str![[r#" .cargo_vcs_info.json Cargo.toml Cargo.toml.orig README.md src/lib.rs -", - ) + +"#]]) .run(); project .cargo("check") .cwd(&new) - .with_stderr( - "\ -[CHECKING] foo v0.5.0 ([CWD]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - ) + .with_stderr_data(str![[r#" +[CHECKING] foo v0.5.0 ([ROOT]/foo2) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -3940,25 +3987,23 @@ fn git_worktree_with_bare_original_repo() { project .cargo("package --list") .cwd(wt.path()) - .with_stdout( - "\ + .with_stdout_data(str![[r#" .cargo_vcs_info.json Cargo.toml Cargo.toml.orig README.md src/lib.rs -", - ) + +"#]]) .run(); project .cargo("check") .cwd(wt.path()) - .with_stderr( - "\ -[CHECKING] foo v0.5.0 ([CWD]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - ) + .with_stderr_data(str![[r#" +[CHECKING] foo v0.5.0 ([ROOT]/bar) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); }