Fix tests

This commit is contained in:
Aleksey Kladov 2020-06-02 18:02:58 +02:00
parent a83ab820a4
commit bc3db7c1de
3 changed files with 270 additions and 69 deletions

View File

@ -228,12 +228,38 @@ fn test_foo() {}
@r###" @r###"
[ [
Runnable { Runnable {
range: 1..21, nav: NavigationTarget {
file_id: FileId(
1,
),
full_range: 1..21,
name: "main",
kind: FN_DEF,
focus_range: Some(
12..16,
),
container_name: None,
description: None,
docs: None,
},
kind: Bin, kind: Bin,
cfg_exprs: [], cfg_exprs: [],
}, },
Runnable { Runnable {
range: 22..46, nav: NavigationTarget {
file_id: FileId(
1,
),
full_range: 22..46,
name: "test_foo",
kind: FN_DEF,
focus_range: Some(
33..41,
),
container_name: None,
description: None,
docs: None,
},
kind: Test { kind: Test {
test_id: Path( test_id: Path(
"test_foo", "test_foo",
@ -245,7 +271,20 @@ fn test_foo() {}
cfg_exprs: [], cfg_exprs: [],
}, },
Runnable { Runnable {
range: 47..81, nav: NavigationTarget {
file_id: FileId(
1,
),
full_range: 47..81,
name: "test_foo",
kind: FN_DEF,
focus_range: Some(
68..76,
),
container_name: None,
description: None,
docs: None,
},
kind: Test { kind: Test {
test_id: Path( test_id: Path(
"test_foo", "test_foo",
@ -280,12 +319,38 @@ fn foo() {}
@r###" @r###"
[ [
Runnable { Runnable {
range: 1..21, nav: NavigationTarget {
file_id: FileId(
1,
),
full_range: 1..21,
name: "main",
kind: FN_DEF,
focus_range: Some(
12..16,
),
container_name: None,
description: None,
docs: None,
},
kind: Bin, kind: Bin,
cfg_exprs: [], cfg_exprs: [],
}, },
Runnable { Runnable {
range: 22..64, nav: NavigationTarget {
file_id: FileId(
1,
),
full_range: 22..64,
name: "foo",
kind: FN_DEF,
focus_range: Some(
56..59,
),
container_name: None,
description: None,
docs: None,
},
kind: DocTest { kind: DocTest {
test_id: Path( test_id: Path(
"foo", "foo",
@ -320,12 +385,38 @@ fn foo() {}
@r###" @r###"
[ [
Runnable { Runnable {
range: 1..21, nav: NavigationTarget {
file_id: FileId(
1,
),
full_range: 1..21,
name: "main",
kind: FN_DEF,
focus_range: Some(
12..16,
),
container_name: None,
description: None,
docs: None,
},
kind: Bin, kind: Bin,
cfg_exprs: [], cfg_exprs: [],
}, },
Runnable { Runnable {
range: 51..105, nav: NavigationTarget {
file_id: FileId(
1,
),
full_range: 51..105,
name: "foo",
kind: FN_DEF,
focus_range: Some(
97..100,
),
container_name: None,
description: None,
docs: None,
},
kind: DocTest { kind: DocTest {
test_id: Path( test_id: Path(
"Data::foo", "Data::foo",
@ -355,14 +446,40 @@ fn test_foo1() {}
@r###" @r###"
[ [
Runnable { Runnable {
range: 1..59, nav: NavigationTarget {
file_id: FileId(
1,
),
full_range: 1..59,
name: "test_mod",
kind: MODULE,
focus_range: Some(
13..21,
),
container_name: None,
description: None,
docs: None,
},
kind: TestMod { kind: TestMod {
path: "test_mod", path: "test_mod",
}, },
cfg_exprs: [], cfg_exprs: [],
}, },
Runnable { Runnable {
range: 28..57, nav: NavigationTarget {
file_id: FileId(
1,
),
full_range: 28..57,
name: "test_foo1",
kind: FN_DEF,
focus_range: Some(
43..52,
),
container_name: None,
description: None,
docs: None,
},
kind: Test { kind: Test {
test_id: Path( test_id: Path(
"test_mod::test_foo1", "test_mod::test_foo1",
@ -397,14 +514,40 @@ fn test_foo1() {}
@r###" @r###"
[ [
Runnable { Runnable {
range: 23..85, nav: NavigationTarget {
file_id: FileId(
1,
),
full_range: 23..85,
name: "test_mod",
kind: MODULE,
focus_range: Some(
27..35,
),
container_name: None,
description: None,
docs: None,
},
kind: TestMod { kind: TestMod {
path: "foo::test_mod", path: "foo::test_mod",
}, },
cfg_exprs: [], cfg_exprs: [],
}, },
Runnable { Runnable {
range: 46..79, nav: NavigationTarget {
file_id: FileId(
1,
),
full_range: 46..79,
name: "test_foo1",
kind: FN_DEF,
focus_range: Some(
65..74,
),
container_name: None,
description: None,
docs: None,
},
kind: Test { kind: Test {
test_id: Path( test_id: Path(
"foo::test_mod::test_foo1", "foo::test_mod::test_foo1",
@ -441,14 +584,40 @@ fn test_foo1() {}
@r###" @r###"
[ [
Runnable { Runnable {
range: 41..115, nav: NavigationTarget {
file_id: FileId(
1,
),
full_range: 41..115,
name: "test_mod",
kind: MODULE,
focus_range: Some(
45..53,
),
container_name: None,
description: None,
docs: None,
},
kind: TestMod { kind: TestMod {
path: "foo::bar::test_mod", path: "foo::bar::test_mod",
}, },
cfg_exprs: [], cfg_exprs: [],
}, },
Runnable { Runnable {
range: 68..105, nav: NavigationTarget {
file_id: FileId(
1,
),
full_range: 68..105,
name: "test_foo1",
kind: FN_DEF,
focus_range: Some(
91..100,
),
container_name: None,
description: None,
docs: None,
},
kind: Test { kind: Test {
test_id: Path( test_id: Path(
"foo::bar::test_mod::test_foo1", "foo::bar::test_mod::test_foo1",
@ -480,7 +649,20 @@ fn test_foo1() {}
@r###" @r###"
[ [
Runnable { Runnable {
range: 1..58, nav: NavigationTarget {
file_id: FileId(
1,
),
full_range: 1..58,
name: "test_foo1",
kind: FN_DEF,
focus_range: Some(
44..53,
),
container_name: None,
description: None,
docs: None,
},
kind: Test { kind: Test {
test_id: Path( test_id: Path(
"test_foo1", "test_foo1",
@ -517,7 +699,20 @@ fn test_foo1() {}
@r###" @r###"
[ [
Runnable { Runnable {
range: 1..80, nav: NavigationTarget {
file_id: FileId(
1,
),
full_range: 1..80,
name: "test_foo1",
kind: FN_DEF,
focus_range: Some(
66..75,
),
container_name: None,
description: None,
docs: None,
},
kind: Test { kind: Test {
test_id: Path( test_id: Path(
"test_foo1", "test_foo1",

View File

@ -139,6 +139,7 @@ pub enum RunnableKind {
#[derive(Deserialize, Serialize, Debug)] #[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct CargoRunnable { pub struct CargoRunnable {
#[serde(skip_serializing_if = "Option::is_none")]
pub workspace_root: Option<PathBuf>, pub workspace_root: Option<PathBuf>,
// command, --package and --lib stuff // command, --package and --lib stuff
pub cargo_args: Vec<String>, pub cargo_args: Vec<String>,

View File

@ -76,30 +76,33 @@ fn foo() {
server.request::<Runnables>( server.request::<Runnables>(
RunnablesParams { text_document: server.doc_id("lib.rs"), position: None }, RunnablesParams { text_document: server.doc_id("lib.rs"), position: None },
json!([ json!([
{ {
"args": [ "test" ], "args": {
"extraArgs": [ "foo", "--nocapture" ], "cargoArgs": ["test"],
"kind": "cargo", "executableArgs": ["foo", "--nocapture"],
"env": { "RUST_BACKTRACE": "short" }, },
"cwd": null, "kind": "cargo",
"label": "test foo", "label": "test foo",
"range": { "location": {
"end": { "character": 1, "line": 2 }, "targetRange": {
"start": { "character": 0, "line": 0 } "end": { "character": 1, "line": 2 },
"start": { "character": 0, "line": 0 }
},
"targetSelectionRange": {
"end": { "character": 6, "line": 1 },
"start": { "character": 3, "line": 1 }
},
"targetUri": "file:///[..]/lib.rs"
}
},
{
"args": {
"cargoArgs": ["check", "--workspace"],
"executableArgs": [],
},
"kind": "cargo",
"label": "cargo check --workspace"
} }
},
{
"args": ["check", "--workspace"],
"extraArgs": [],
"kind": "cargo",
"env": {},
"cwd": null,
"label": "cargo check --workspace",
"range": {
"end": { "character": 0, "line": 0 },
"start": { "character": 0, "line": 0 }
}
}
]), ]),
); );
} }
@ -138,42 +141,44 @@ fn main() {}
server.request::<Runnables>( server.request::<Runnables>(
RunnablesParams { text_document: server.doc_id("foo/tests/spam.rs"), position: None }, RunnablesParams { text_document: server.doc_id("foo/tests/spam.rs"), position: None },
json!([ json!([
{ {
"args": [ "test", "--package", "foo", "--test", "spam" ], "args": {
"extraArgs": [ "test_eggs", "--exact", "--nocapture" ], "cargoArgs": ["test", "--package", "foo", "--test", "spam"],
"kind": "cargo", "executableArgs": ["test_eggs", "--exact", "--nocapture"],
"env": { "RUST_BACKTRACE": "short" }, "workspaceRoot": server.path().join("foo")
"label": "test test_eggs", },
"range": { "kind": "cargo",
"label": "test test_eggs",
"location": {
"targetRange": {
"end": { "character": 17, "line": 1 }, "end": { "character": 17, "line": 1 },
"start": { "character": 0, "line": 0 } "start": { "character": 0, "line": 0 }
}, },
"cwd": server.path().join("foo") "targetSelectionRange": {
}, "end": { "character": 12, "line": 1 },
{ "start": { "character": 3, "line": 1 }
"args": [ "check", "--package", "foo" ],
"extraArgs": [],
"kind": "cargo",
"env": {},
"label": "cargo check -p foo",
"range": {
"end": { "character": 0, "line": 0 },
"start": { "character": 0, "line": 0 }
}, },
"cwd": server.path().join("foo") "targetUri": "file:///[..]/tests/spam.rs"
},
{
"args": [ "test", "--package", "foo" ],
"extraArgs": [],
"kind": "cargo",
"env": {},
"label": "cargo test -p foo",
"range": {
"end": { "character": 0, "line": 0 },
"start": { "character": 0, "line": 0 }
},
"cwd": server.path().join("foo")
} }
},
{
"args": {
"cargoArgs": ["check", "--package", "foo"],
"executableArgs": [],
"workspaceRoot": server.path().join("foo")
},
"kind": "cargo",
"label": "cargo check -p foo"
},
{
"args": {
"cargoArgs": ["test", "--package", "foo"],
"executableArgs": [],
"workspaceRoot": server.path().join("foo")
},
"kind": "cargo",
"label": "cargo test -p foo"
}
]), ]),
); );
} }