Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
matklad committed Jun 2, 2020
1 parent a83ab82 commit dd0c978
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 54 deletions.
1 change: 1 addition & 0 deletions crates/rust-analyzer/src/lsp_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ pub enum RunnableKind {
#[derive(Deserialize, Serialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct CargoRunnable {
#[serde(skip_serializing_if = "Option::is_none")]
pub workspace_root: Option<PathBuf>,
// command, --package and --lib stuff
pub cargo_args: Vec<String>,
Expand Down
113 changes: 59 additions & 54 deletions crates/rust-analyzer/tests/heavy_tests/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,30 +76,33 @@ fn foo() {
server.request::<Runnables>(
RunnablesParams { text_document: server.doc_id("lib.rs"), position: None },
json!([
{
"args": [ "test" ],
"extraArgs": [ "foo", "--nocapture" ],
"kind": "cargo",
"env": { "RUST_BACKTRACE": "short" },
"cwd": null,
"label": "test foo",
"range": {
"end": { "character": 1, "line": 2 },
"start": { "character": 0, "line": 0 }
}
},
{
"args": ["check", "--workspace"],
"extraArgs": [],
"kind": "cargo",
"env": {},
"cwd": null,
"label": "cargo check --workspace",
"range": {
"end": { "character": 0, "line": 0 },
"start": { "character": 0, "line": 0 }
{
"args": {
"cargoArgs": ["test"],
"executableArgs": ["foo", "--nocapture"],
},
"kind": "cargo",
"label": "test foo",
"location": {
"targetRange": {
"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"
}
}
]),
);
}
Expand Down Expand Up @@ -138,42 +141,44 @@ fn main() {}
server.request::<Runnables>(
RunnablesParams { text_document: server.doc_id("foo/tests/spam.rs"), position: None },
json!([
{
"args": [ "test", "--package", "foo", "--test", "spam" ],
"extraArgs": [ "test_eggs", "--exact", "--nocapture" ],
"kind": "cargo",
"env": { "RUST_BACKTRACE": "short" },
"label": "test test_eggs",
"range": {
"end": { "character": 17, "line": 1 },
"start": { "character": 0, "line": 0 }
},
"cwd": server.path().join("foo")
{
"args": {
"cargoArgs": ["test", "--package", "foo", "--test", "spam"],
"executableArgs": ["test_eggs", "--exact", "--nocapture"],
"workspaceRoot": server.path().join("foo")
},
{
"args": [ "check", "--package", "foo" ],
"extraArgs": [],
"kind": "cargo",
"env": {},
"label": "cargo check -p foo",
"range": {
"end": { "character": 0, "line": 0 },
"kind": "cargo",
"label": "test test_eggs",
"location": {
"targetRange": {
"end": { "character": 17, "line": 1 },
"start": { "character": 0, "line": 0 }
},
"cwd": server.path().join("foo")
},
{
"args": [ "test", "--package", "foo" ],
"extraArgs": [],
"kind": "cargo",
"env": {},
"label": "cargo test -p foo",
"range": {
"end": { "character": 0, "line": 0 },
"start": { "character": 0, "line": 0 }
"targetSelectionRange": {
"end": { "character": 12, "line": 1 },
"start": { "character": 3, "line": 1 }
},
"cwd": server.path().join("foo")
"targetUri": "file:///[..]/tests/spam.rs"
}
},
{
"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"
}
]),
);
}
Expand Down

0 comments on commit dd0c978

Please sign in to comment.