-
Notifications
You must be signed in to change notification settings - Fork 474
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LS: Add first tests for the new project model
commit-id:7caaac0c
- Loading branch information
Showing
14 changed files
with
282 additions
and
21 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
//! This module contains definitions of custom methods (aka requests or notifications) for the | ||
//! Language Server Protocol that are provided by the Cairo Language Server. | ||
|
||
use tower_lsp::lsp_types::request::Request; | ||
|
||
#[cfg(feature = "testing")] | ||
pub mod test { | ||
use super::*; | ||
|
||
pub struct DebugProjects; | ||
impl Request for DebugProjects { | ||
type Params = (); | ||
type Result = String; | ||
const METHOD: &'static str = "test/debugProjects"; | ||
} | ||
} |
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
pub mod client_capabilities; | ||
pub(crate) mod client_capabilities; | ||
pub mod methods; |
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
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
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
mod project; | ||
mod semantic_tokens; | ||
mod support; |
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,59 @@ | ||
use cairo_lang_language_server::lsp; | ||
|
||
use crate::support::normalize::assert_normalized_eq; | ||
use crate::support::sandbox; | ||
|
||
#[test] | ||
fn cairo_projects() { | ||
let mut ls = sandbox! { | ||
files { | ||
"project1/cairo_project.toml" => r#" | ||
[crate_roots] | ||
project1 = "src" | ||
[config.global] | ||
edition = "2023_11" | ||
"#, | ||
"project1/src/lib.cairo" => r#"fn main() {}"#, | ||
|
||
"project2/cairo_project.toml" => r#" | ||
[crate_roots] | ||
project2 = "src" | ||
[config.global] | ||
edition = "2023_11" | ||
"#, | ||
"project2/src/lib.cairo" => r#"fn main() {}"#, | ||
|
||
"project2/subproject/cairo_project.toml" => r#" | ||
[crate_roots] | ||
subproject = "src" | ||
[config.global] | ||
edition = "2023_11" | ||
"#, | ||
"project2/subproject/src/lib.cairo" => r#"fn main() {}"#, | ||
} | ||
}; | ||
|
||
ls.open_and_wait_for_diagnostics("project1/src/lib.cairo"); | ||
ls.open_and_wait_for_diagnostics("project2/src/lib.cairo"); | ||
ls.open_and_wait_for_diagnostics("project2/subproject/src/lib.cairo"); | ||
|
||
let projects = ls.send_request::<lsp::methods::test::DebugProjects>(()); | ||
assert_normalized_eq!( | ||
&ls, | ||
projects, | ||
r#"[ | ||
CairoProject { | ||
project_path: "[ROOT]/project2/subproject/cairo_project.toml", | ||
}, | ||
CairoProject { | ||
project_path: "[ROOT]/project2/cairo_project.toml", | ||
}, | ||
CairoProject { | ||
project_path: "[ROOT]/project1/cairo_project.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
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
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
Oops, something went wrong.