-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added logic to preserve carriage returns when updating the manifest file
- Loading branch information
1 parent
0276088
commit 791460f
Showing
13 changed files
with
194 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
tests/testsuite/cargo_add/preserve_carriage_returns/in/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[workspace] | ||
|
||
[package] | ||
name = "cargo-list-test-fixture" | ||
version = "0.0.0" | ||
edition = "2015" |
Empty file.
36 changes: 36 additions & 0 deletions
36
tests/testsuite/cargo_add/preserve_carriage_returns/mod.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
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::str; | ||
use cargo_test_support::Project; | ||
|
||
#[cargo_test] | ||
fn case() { | ||
cargo_test_support::registry::init(); | ||
cargo_test_support::registry::Package::new("my-package", "0.1.0").publish(); | ||
|
||
let project = Project::from_template(current_dir!().join("in")); | ||
let project_root = project.root(); | ||
let cwd = &project_root; | ||
|
||
snapbox::cmd::Command::cargo_ui() | ||
.arg("add") | ||
.arg_line("my-package") | ||
.current_dir(cwd) | ||
.assert() | ||
.success() | ||
.stdout_eq(str![""]) | ||
.stderr_eq(file!["stderr.term.svg"]); | ||
|
||
// Verify the content matches first (for nicer error output) | ||
assert_ui().subset_matches(current_dir!().join("out"), &project_root); | ||
|
||
// Snapbox normalizes lines so we also need to do a string comparision to verify line endings | ||
let expected = current_dir!().join("out/Cargo.toml"); | ||
let actual = project_root.join("Cargo.toml"); | ||
assert_eq!( | ||
std::fs::read_to_string(expected).unwrap(), | ||
std::fs::read_to_string(actual).unwrap() | ||
); | ||
} |
9 changes: 9 additions & 0 deletions
9
tests/testsuite/cargo_add/preserve_carriage_returns/out/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[workspace] | ||
|
||
[package] | ||
name = "cargo-list-test-fixture" | ||
version = "0.0.0" | ||
edition = "2015" | ||
|
||
[dependencies] | ||
my-package = "0.1.0" |
31 changes: 31 additions & 0 deletions
31
tests/testsuite/cargo_add/preserve_carriage_returns/stderr.term.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
tests/testsuite/cargo_remove/preserve_carriage_returns/in/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[workspace] | ||
|
||
[package] | ||
name = "cargo-list-test-fixture" | ||
version = "0.0.0" | ||
edition = "2015" | ||
|
||
[dependencies] | ||
my-package = "0.1.0" |
Empty file.
36 changes: 36 additions & 0 deletions
36
tests/testsuite/cargo_remove/preserve_carriage_returns/mod.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
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::str; | ||
use cargo_test_support::Project; | ||
|
||
#[cargo_test] | ||
fn case() { | ||
cargo_test_support::registry::init(); | ||
cargo_test_support::registry::Package::new("my-package", "0.1.0").publish(); | ||
|
||
let project = Project::from_template(current_dir!().join("in")); | ||
let project_root = project.root(); | ||
let cwd = &project_root; | ||
|
||
snapbox::cmd::Command::cargo_ui() | ||
.arg("remove") | ||
.arg_line("my-package") | ||
.current_dir(cwd) | ||
.assert() | ||
.success() | ||
.stdout_eq(str![""]) | ||
.stderr_eq(file!["stderr.term.svg"]); | ||
|
||
// Verify the content matches first (for nicer error output) | ||
assert_ui().subset_matches(current_dir!().join("out"), &project_root); | ||
|
||
// Snapbox normalizes lines so we also need to do a string comparision to verify line endings | ||
let expected = current_dir!().join("out/Cargo.toml"); | ||
let actual = project_root.join("Cargo.toml"); | ||
assert_eq!( | ||
std::fs::read_to_string(expected).unwrap(), | ||
std::fs::read_to_string(actual).unwrap() | ||
); | ||
} |
6 changes: 6 additions & 0 deletions
6
tests/testsuite/cargo_remove/preserve_carriage_returns/out/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[workspace] | ||
|
||
[package] | ||
name = "cargo-list-test-fixture" | ||
version = "0.0.0" | ||
edition = "2015" |
27 changes: 27 additions & 0 deletions
27
tests/testsuite/cargo_remove/preserve_carriage_returns/stderr.term.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.