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

Commit 5d35c95

Browse files
committed
Add simple test for basic workspace support
1 parent 7dac529 commit 5d35c95

File tree

7 files changed

+67
-0
lines changed

7 files changed

+67
-0
lines changed

src/test/mod.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,30 @@ fn test_bin_lib_project_no_cfg_test() {
437437
ExpectedMessage::new(None).expect_contains("diagnosticsEnd")]);
438438
}
439439

440+
#[test]
441+
fn test_simple_workspace() {
442+
let (cache, _tc) = init_env("simple_workspace");
443+
444+
let root_path = cache.abs_path(Path::new("."));
445+
446+
let messages = vec![
447+
ServerMessage::initialize(0, root_path.as_os_str().to_str().map(|x| x.to_owned())),
448+
];
449+
450+
let mut config = Config::default();
451+
config.workspace_mode = true;
452+
let (server, results) = mock_server_with_config(messages, config);
453+
// Initialise and build.
454+
assert_eq!(ls_server::LsService::handle_message(server.clone()),
455+
ls_server::ServerStateChange::Continue);
456+
expect_messages(results.clone(), &[ExpectedMessage::new(Some(0)).expect_contains("capabilities"),
457+
ExpectedMessage::new(None).expect_contains("diagnosticsBegin"),
458+
// TODO: it'd be convenient to test if compilation encountered an internal error
459+
// or at least to check stderr's contents. We shouldn't check for presence of a warning here
460+
ExpectedMessage::new(None).expect_contains("unused variable: `a`"),
461+
ExpectedMessage::new(None).expect_contains("diagnosticsEnd")]);
462+
}
463+
440464
#[test]
441465
fn test_parse_error_on_malformed_input() {
442466
let _ = env_logger::init();

test_data/simple_workspace/Cargo.lock

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test_data/simple_workspace/Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[workspace]
2+
members = [
3+
"member_lib",
4+
"member_bin",
5+
]
6+
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[package]
2+
name = "member_bin"
3+
version = "0.1.0"
4+
authors = ["Igor Matuszewski <[email protected]>"]
5+
6+
[dependencies]
7+
member_lib = { path = "../member_lib" }
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
extern crate member_lib;
2+
3+
fn main() {
4+
let a = member_lib::MemberLibStruct;
5+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[package]
2+
name = "member_lib"
3+
version = "0.1.0"
4+
authors = ["Igor Matuszewski <[email protected]>"]
5+
6+
[dependencies]
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
pub struct MemberLibStruct;
2+
3+
#[cfg(test)]
4+
mod tests {
5+
#[test]
6+
fn it_works() {
7+
}
8+
}

0 commit comments

Comments
 (0)