Skip to content
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.

Commit

Permalink
Merge pull request #1694 from cuviper/typo-autocfg
Browse files Browse the repository at this point in the history
Test typos with autocfg
  • Loading branch information
Xanewok authored Nov 18, 2020
2 parents dab1468 + ec349b9 commit dd96b56
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions tests/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -631,11 +631,11 @@ fn client_use_statement_completion_doesnt_suggest_arguments() {
///
/// ```
/// [dependencies]
/// version-check = "0.5555"
/// auto-cfg = "0.5555"
/// ```
///
/// * Firstly "version-check" doesn't exist, it should be "version_check"
/// * Secondly version 0.5555 of "version_check" doesn't exist.
/// * Firstly "auto-cfg" doesn't exist, it should be "autocfg"
/// * Secondly version 0.5555 of "autocfg" doesn't exist.
#[test]
fn client_dependency_typo_and_fix() {
let manifest_with_dependency = |dep: &str| {
Expand All @@ -654,7 +654,7 @@ fn client_dependency_typo_and_fix() {
};

let p = project("dependency_typo")
.file("Cargo.toml", &manifest_with_dependency(r#"version-check = "0.5555""#))
.file("Cargo.toml", &manifest_with_dependency(r#"auto-cfg = "0.5555""#))
.file(
"src/main.rs",
r#"
Expand All @@ -672,14 +672,14 @@ fn client_dependency_typo_and_fix() {
let diag = rls.wait_for_diagnostics();
assert_eq!(diag.diagnostics.len(), 1);
assert_eq!(diag.diagnostics[0].severity, Some(DiagnosticSeverity::Error));
assert!(diag.diagnostics[0].message.contains("no matching package named `version-check`"));
assert!(diag.diagnostics[0].message.contains("no matching package named `auto-cfg`"));

let change_manifest = |contents: &str| {
std::fs::write(root_path.join("Cargo.toml"), contents).unwrap();
};

// fix naming typo, we now expect a version error diagnostic
change_manifest(&manifest_with_dependency(r#"version_check = "0.5555""#));
change_manifest(&manifest_with_dependency(r#"autocfg = "0.5555""#));
rls.notify::<DidChangeWatchedFiles>(DidChangeWatchedFilesParams {
changes: vec![FileEvent {
uri: Url::from_file_path(p.root().join("Cargo.toml")).unwrap(),
Expand All @@ -694,8 +694,8 @@ fn client_dependency_typo_and_fix() {

// Fix version issue so no error diagnostics occur.
// This is kinda slow as cargo will compile the dependency, though I
// chose version_check to minimise this as it is a very small dependency.
change_manifest(&manifest_with_dependency(r#"version_check = "0.1""#));
// chose autocfg to minimise this as it is a very small dependency.
change_manifest(&manifest_with_dependency(r#"autocfg = "1""#));
rls.notify::<DidChangeWatchedFiles>(DidChangeWatchedFilesParams {
changes: vec![FileEvent {
uri: Url::from_file_path(p.root().join("Cargo.toml")).unwrap(),
Expand Down

0 comments on commit dd96b56

Please sign in to comment.