Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/bin/cargo/commands/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,12 @@ pub fn exec(gctx: &mut GlobalContext, args: &ArgMatches) -> CliResult {
.into());
}
}

if crate_name != "."
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

. is special cased later to warn that cargo install . is deprecated

&& let Err(e) = package_name
{
return Err(anyhow::format_err!("{e}").into());
}
}

let mut from_cwd = false;
Expand Down
39 changes: 39 additions & 0 deletions tests/testsuite/install.rs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, for bugfixes, we usually follow a variant of atomic commit pattern:

  1. Commit a test that asserts the current buggy behavior (passes).
  2. In the next commit, fix the bug and update the test/snapshot.

Every commit passes, and the test/snapshot diff shows the behavior change.

Would you mind rearranging your commit history to follow that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@weihanglo just pushed up the changes

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update!

Original file line number Diff line number Diff line change
Expand Up @@ -3068,3 +3068,42 @@ For more information, try '--help'.
"#]])
.run();
}

#[cargo_test]
fn emoji_name() {
pkg("foo", "0.0.1");
cargo_process("install 🦀")
.with_status(101)
.with_stdout_data("")
.with_stderr_data(str![[r#"
[ERROR] invalid character `🦀` in package name: `🦀`, the first character must be a Unicode XID start character (most letters or `_`)

"#]])
.run();
}

#[cargo_test]
fn starts_with_number_case() {
pkg("foo", "0.0.1");
cargo_process("install 23898932983")
.with_status(101)
.with_stdout_data("")
.with_stderr_data(str![[r#"
[ERROR] invalid character `2` in package name: `23898932983`, the name cannot start with a digit

"#]])
.run();
}

#[cargo_test]
fn mistaken_flag_case() {
pkg("foo", "0.0.1");
cargo_process("install ––path .") // en dashes
.with_status(101)
.with_stdout_data("")
.with_stderr_data(str![[r#"
[ERROR] invalid character `–` in package name: `––path`, the first character must be a Unicode XID start character (most letters or `_`)

"#]])
.run();
}