From 3751c543196c2907221971a8953e2cb5329e121b Mon Sep 17 00:00:00 2001 From: hi-rustin Date: Wed, 19 Apr 2023 09:39:33 +0800 Subject: [PATCH] Add test for empty dep table error Signed-off-by: hi-rustin --- .../cargo_add/add-basic.in/Cargo.toml | 3 +++ tests/testsuite/cargo_add/empty_dep_table/in | 1 + .../cargo_add/empty_dep_table/mod.rs | 25 +++++++++++++++++++ .../cargo_add/empty_dep_table/out/Cargo.toml | 8 ++++++ .../cargo_add/empty_dep_table/stderr.log | 1 + .../cargo_add/empty_dep_table/stdout.log | 0 tests/testsuite/cargo_add/mod.rs | 1 + 7 files changed, 39 insertions(+) create mode 120000 tests/testsuite/cargo_add/empty_dep_table/in create mode 100644 tests/testsuite/cargo_add/empty_dep_table/mod.rs create mode 100644 tests/testsuite/cargo_add/empty_dep_table/out/Cargo.toml create mode 100644 tests/testsuite/cargo_add/empty_dep_table/stderr.log create mode 100644 tests/testsuite/cargo_add/empty_dep_table/stdout.log diff --git a/tests/testsuite/cargo_add/add-basic.in/Cargo.toml b/tests/testsuite/cargo_add/add-basic.in/Cargo.toml index 3ecdb6681676..cac16bb94721 100644 --- a/tests/testsuite/cargo_add/add-basic.in/Cargo.toml +++ b/tests/testsuite/cargo_add/add-basic.in/Cargo.toml @@ -3,3 +3,6 @@ [package] name = "cargo-list-test-fixture" version = "0.0.0" + +[dependencies] +your-face = { } diff --git a/tests/testsuite/cargo_add/empty_dep_table/in b/tests/testsuite/cargo_add/empty_dep_table/in new file mode 120000 index 000000000000..6c6a27fcfb58 --- /dev/null +++ b/tests/testsuite/cargo_add/empty_dep_table/in @@ -0,0 +1 @@ +../add-basic.in \ No newline at end of file diff --git a/tests/testsuite/cargo_add/empty_dep_table/mod.rs b/tests/testsuite/cargo_add/empty_dep_table/mod.rs new file mode 100644 index 000000000000..f6c507188ade --- /dev/null +++ b/tests/testsuite/cargo_add/empty_dep_table/mod.rs @@ -0,0 +1,25 @@ +use cargo_test_support::compare::assert_ui; +use cargo_test_support::prelude::*; +use cargo_test_support::Project; + +use crate::cargo_add::init_registry; +use cargo_test_support::curr_dir; + +#[cargo_test] +fn case() { + init_registry(); + let project = Project::from_template(curr_dir!().join("in")); + let project_root = project.root(); + let cwd = &project_root; + + snapbox::cmd::Command::cargo_ui() + .arg("add") + .arg_line("your-face --features eyes") + .current_dir(cwd) + .assert() + .code(101) + .stdout_matches_path(curr_dir!().join("stdout.log")) + .stderr_matches_path(curr_dir!().join("stderr.log")); + + assert_ui().subset_matches(curr_dir!().join("out"), &project_root); +} diff --git a/tests/testsuite/cargo_add/empty_dep_table/out/Cargo.toml b/tests/testsuite/cargo_add/empty_dep_table/out/Cargo.toml new file mode 100644 index 000000000000..cac16bb94721 --- /dev/null +++ b/tests/testsuite/cargo_add/empty_dep_table/out/Cargo.toml @@ -0,0 +1,8 @@ +[workspace] + +[package] +name = "cargo-list-test-fixture" +version = "0.0.0" + +[dependencies] +your-face = { } diff --git a/tests/testsuite/cargo_add/empty_dep_table/stderr.log b/tests/testsuite/cargo_add/empty_dep_table/stderr.log new file mode 100644 index 000000000000..00b1db5e3692 --- /dev/null +++ b/tests/testsuite/cargo_add/empty_dep_table/stderr.log @@ -0,0 +1 @@ +error: Unrecognized dependency source for `your-face`, expected a table with a `version`, `git`, `path`, or `workspace` key diff --git a/tests/testsuite/cargo_add/empty_dep_table/stdout.log b/tests/testsuite/cargo_add/empty_dep_table/stdout.log new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tests/testsuite/cargo_add/mod.rs b/tests/testsuite/cargo_add/mod.rs index ca58474d2196..26a11dd8a493 100644 --- a/tests/testsuite/cargo_add/mod.rs +++ b/tests/testsuite/cargo_add/mod.rs @@ -15,6 +15,7 @@ mod dev; mod dev_build_conflict; mod dev_prefer_existing_version; mod dry_run; +mod empty_dep_table; mod features; mod features_empty; mod features_multiple_occurrences;