diff options
Diffstat (limited to 'test_util/src')
-rw-r--r-- | test_util/src/builders.rs | 15 | ||||
-rw-r--r-- | test_util/src/fs.rs | 4 | ||||
-rw-r--r-- | test_util/src/lsp.rs | 10 |
3 files changed, 25 insertions, 4 deletions
diff --git a/test_util/src/builders.rs b/test_util/src/builders.rs index 48c001a7e..bdc5efbe0 100644 --- a/test_util/src/builders.rs +++ b/test_util/src/builders.rs @@ -19,7 +19,6 @@ use crate::env_vars_for_npm_tests_no_sync_download; use crate::fs::PathRef; use crate::http_server; use crate::lsp::LspClientBuilder; -use crate::new_deno_dir; use crate::pty::Pty; use crate::strip_ansi_codes; use crate::testdata_path; @@ -36,6 +35,7 @@ pub struct TestContextBuilder { /// to the temp folder and runs the test from there. This is useful when /// the test creates files in the testdata directory (ex. a node_modules folder) copy_temp_dir: Option<String>, + temp_dir_path: Option<PathBuf>, cwd: Option<String>, envs: HashMap<String, String>, deno_exe: Option<PathRef>, @@ -50,6 +50,11 @@ impl TestContextBuilder { Self::new().use_http_server().add_npm_env_vars() } + pub fn temp_dir_path(mut self, path: impl AsRef<Path>) -> Self { + self.temp_dir_path = Some(path.as_ref().to_path_buf()); + self + } + pub fn use_http_server(mut self) -> Self { self.use_http_server = true; self @@ -117,9 +122,13 @@ impl TestContextBuilder { } pub fn build(&self) -> TestContext { - let deno_dir = new_deno_dir(); // keep this alive for the test + let temp_dir_path = self + .temp_dir_path + .clone() + .unwrap_or_else(std::env::temp_dir); + let deno_dir = TempDir::new_in(&temp_dir_path); let temp_dir = if self.use_separate_deno_dir { - TempDir::new() + TempDir::new_in(&temp_dir_path) } else { deno_dir.clone() }; diff --git a/test_util/src/fs.rs b/test_util/src/fs.rs index f9443c9c5..2a64fb9c4 100644 --- a/test_util/src/fs.rs +++ b/test_util/src/fs.rs @@ -324,6 +324,10 @@ impl TempDir { Self::new_inner(&std::env::temp_dir(), Some(prefix)) } + pub fn new_in(parent_dir: &Path) -> Self { + Self::new_inner(parent_dir, None) + } + pub fn new_with_path(path: &Path) -> Self { Self(Arc::new(TempDirInner::Path(PathRef(path.to_path_buf())))) } diff --git a/test_util/src/lsp.rs b/test_util/src/lsp.rs index 6fafc234c..59f67e3d9 100644 --- a/test_util/src/lsp.rs +++ b/test_util/src/lsp.rs @@ -641,16 +641,24 @@ impl LspClient { .stderr_lines_rx .as_ref() .expect("must setup with client_builder.capture_stderr()"); + let mut found_lines = Vec::new(); while Instant::now() < timeout_time { if let Ok(line) = lines_rx.try_recv() { if condition(&line) { return; } + found_lines.push(line); } std::thread::sleep(Duration::from_millis(20)); } - panic!("Timed out.") + eprintln!("==== STDERR OUTPUT ===="); + for line in found_lines { + eprintln!("{}", line) + } + eprintln!("== END STDERR OUTPUT =="); + + panic!("Timed out waiting on condition.") } pub fn initialize_default(&mut self) { |