-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
5 changed files
with
203 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
mod simple_deps; |
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,46 @@ | ||
use cairo_lang_test_utils::parse_test_file::TestRunnerResult; | ||
use cairo_lang_utils::ordered_hash_map::OrderedHashMap; | ||
use cairo_language_server::lsp; | ||
use lsp_types::NumberOrString; | ||
|
||
use crate::support::normalize::normalize; | ||
use crate::support::sandbox; | ||
|
||
cairo_lang_test_utils::test_file_test!( | ||
simple_deps, | ||
"tests/test_data/scarb", | ||
{ | ||
simple_deps: "simple_deps.txt" | ||
}, | ||
test_simple_deps | ||
); | ||
|
||
fn test_simple_deps( | ||
inputs: &OrderedHashMap<String, String>, | ||
_args: &OrderedHashMap<String, String>, | ||
) -> TestRunnerResult { | ||
let mut ls = sandbox! { | ||
files { | ||
"a/Scarb.toml" => &inputs["a/Scarb.toml"], | ||
"a/src/lib.cairo" => &inputs["a/src/lib.cairo"], | ||
"b/Scarb.toml" => &inputs["b/Scarb.toml"], | ||
"b/src/lib.cairo" => &inputs["b/src/lib.cairo"], | ||
} | ||
}; | ||
|
||
assert!(ls.open_and_wait_for_diagnostics("a/src/lib.cairo").diagnostics.is_empty()); | ||
// Check if opening `a` triggers calculating diagnostics for `b`. | ||
let diagnostics_from_b = ls.wait_for_diagnostics("b/src/lib.cairo"); | ||
assert_eq!(diagnostics_from_b.diagnostics.len(), 1); | ||
assert_eq!( | ||
diagnostics_from_b.diagnostics[0].code, | ||
Some(NumberOrString::String("E0005".to_string())) | ||
); | ||
|
||
let analyzed_crates = ls.send_request::<lsp::ext::ViewAnalyzedCrates>(()); | ||
|
||
TestRunnerResult::success(OrderedHashMap::from([( | ||
"Analyzed crates".to_string(), | ||
normalize(&ls, analyzed_crates), | ||
)])) | ||
} |
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,154 @@ | ||
//! > Test simple Scarb deps. | ||
|
||
//! > test_runner_name | ||
test_simple_deps | ||
|
||
//! > a/Scarb.toml | ||
[package] | ||
name = "a" | ||
version = "0.1.0" | ||
edition = "2024_07" | ||
|
||
[dependencies] | ||
b = { path = "../b" } | ||
|
||
//! > a/src/lib.cairo | ||
use b::Foo; | ||
|
||
fn main() { | ||
let foo = Foo::Bar; | ||
match foo { | ||
Foo::Baz => {}, | ||
_ => {} | ||
} | ||
} | ||
|
||
//! > b/Scarb.toml | ||
[package] | ||
name = "b" | ||
version = "0.1.0" | ||
edition = "2024_07" | ||
|
||
//! > b/src/lib.cairo | ||
pub enum Foo { | ||
Bar, | ||
Baz, | ||
} | ||
|
||
mod non_existent; | ||
|
||
//! > Analyzed crates | ||
# Analyzed Crates | ||
|
||
- `a`: `["[ROOT]/a/src/lib.cairo"]` | ||
```rust | ||
CrateSettings { | ||
name: Some( | ||
"a", | ||
), | ||
edition: V2024_07, | ||
version: Some( | ||
Version { | ||
major: 0, | ||
minor: 1, | ||
patch: 0, | ||
}, | ||
), | ||
cfg_set: Some( | ||
CfgSet( | ||
target: "lib", | ||
target: "test", | ||
test, | ||
), | ||
), | ||
dependencies: { | ||
"a": DependencySettings { | ||
discriminator: Some( | ||
"a 0.1.0 (path+[ROOT_URL]a/Scarb.toml)", | ||
), | ||
}, | ||
"b": DependencySettings { | ||
discriminator: Some( | ||
"b 0.1.0 (path+[ROOT_URL]b/Scarb.toml)", | ||
), | ||
}, | ||
"core": DependencySettings { | ||
discriminator: None, | ||
}, | ||
}, | ||
experimental_features: ExperimentalFeaturesConfig { | ||
negative_impls: false, | ||
associated_item_constraints: false, | ||
coupons: false, | ||
}, | ||
} | ||
``` | ||
- `b`: `["[ROOT]/b/src/lib.cairo"]` | ||
```rust | ||
CrateSettings { | ||
name: Some( | ||
"b", | ||
), | ||
edition: V2024_07, | ||
version: Some( | ||
Version { | ||
major: 0, | ||
minor: 1, | ||
patch: 0, | ||
}, | ||
), | ||
cfg_set: Some( | ||
CfgSet( | ||
target: "lib", | ||
target: "test", | ||
), | ||
), | ||
dependencies: { | ||
"b": DependencySettings { | ||
discriminator: Some( | ||
"b 0.1.0 (path+[ROOT_URL]b/Scarb.toml)", | ||
), | ||
}, | ||
"core": DependencySettings { | ||
discriminator: None, | ||
}, | ||
}, | ||
experimental_features: ExperimentalFeaturesConfig { | ||
negative_impls: false, | ||
associated_item_constraints: false, | ||
coupons: false, | ||
}, | ||
} | ||
``` | ||
- `core`: `["[SCARB_REGISTRY_STD]/core/src/lib.cairo"]` | ||
```rust | ||
CrateSettings { | ||
name: Some( | ||
"core", | ||
), | ||
edition: V2024_07, | ||
version: Some( | ||
Version { | ||
major: 2, | ||
minor: 9, | ||
patch: 1, | ||
}, | ||
), | ||
cfg_set: Some( | ||
CfgSet( | ||
target: "lib", | ||
target: "test", | ||
), | ||
), | ||
dependencies: { | ||
"core": DependencySettings { | ||
discriminator: None, | ||
}, | ||
}, | ||
experimental_features: ExperimentalFeaturesConfig { | ||
negative_impls: true, | ||
associated_item_constraints: true, | ||
coupons: true, | ||
}, | ||
} | ||
``` |