summaryrefslogtreecommitdiff
path: root/cli/lsp/diagnostics.rs
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2022-04-01 11:15:37 -0400
committerGitHub <noreply@github.com>2022-04-01 11:15:37 -0400
commit1c37ac33526dc45ad0b3f83ca8294dbb55548096 (patch)
tree426978168928c5e7c2223e4906005fa23fb34cd6 /cli/lsp/diagnostics.rs
parent8ca4c1819f3e7a8716c68034e256355334d53b44 (diff)
chore(tests): use custom temp dir creation for the tests (#14153)
Diffstat (limited to 'cli/lsp/diagnostics.rs')
-rw-r--r--cli/lsp/diagnostics.rs36
1 files changed, 22 insertions, 14 deletions
diff --git a/cli/lsp/diagnostics.rs b/cli/lsp/diagnostics.rs
index 59fc1c43b..fd905f6e0 100644
--- a/cli/lsp/diagnostics.rs
+++ b/cli/lsp/diagnostics.rs
@@ -884,7 +884,7 @@ mod tests {
use crate::lsp::language_server::StateSnapshot;
use std::path::Path;
use std::path::PathBuf;
- use tempfile::TempDir;
+ use test_util::TempDir;
fn mock_state_snapshot(
fixtures: &[(&str, &str, i32, LanguageId)],
@@ -922,9 +922,9 @@ mod tests {
}
fn setup(
+ temp_dir: &TempDir,
sources: &[(&str, &str, i32, LanguageId)],
) -> (StateSnapshot, PathBuf) {
- let temp_dir = TempDir::new().expect("could not create temp dir");
let location = temp_dir.path().join("deps");
let state_snapshot = mock_state_snapshot(sources, &location);
(state_snapshot, location)
@@ -932,16 +932,20 @@ mod tests {
#[tokio::test]
async fn test_enabled_then_disabled_specifier() {
+ let temp_dir = TempDir::new();
let specifier = ModuleSpecifier::parse("file:///a.ts").unwrap();
- let (snapshot, _) = setup(&[(
- "file:///a.ts",
- r#"import * as b from "./b.ts";
+ let (snapshot, _) = setup(
+ &temp_dir,
+ &[(
+ "file:///a.ts",
+ r#"import * as b from "./b.ts";
let a: any = "a";
let c: number = "a";
"#,
- 1,
- LanguageId::TypeScript,
- )]);
+ 1,
+ LanguageId::TypeScript,
+ )],
+ );
let snapshot = Arc::new(snapshot);
let ts_server = TsServer::new(Default::default());
@@ -1026,12 +1030,16 @@ let c: number = "a";
#[tokio::test]
async fn test_cancelled_ts_diagnostics_request() {
- let (snapshot, _) = setup(&[(
- "file:///a.ts",
- r#"export let a: string = 5;"#,
- 1,
- LanguageId::TypeScript,
- )]);
+ let temp_dir = TempDir::new();
+ let (snapshot, _) = setup(
+ &temp_dir,
+ &[(
+ "file:///a.ts",
+ r#"export let a: string = 5;"#,
+ 1,
+ LanguageId::TypeScript,
+ )],
+ );
let snapshot = Arc::new(snapshot);
let ts_server = TsServer::new(Default::default());