debugger: Fix running JS tests when worktree root and package root do not coincide (#32644)
- construct the correct path to the test library based on the location of package.json - run scripts from the package root where they were defined - run tests in the directory of the defining file Release Notes: - Debugger Beta: fixed running JS tests when the worktree root is above the location of package.json. --------- Co-authored-by: Anthony <anthony@zed.dev> Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
This commit is contained in:
parent
9166e66519
commit
bcd79331b9
3 changed files with 289 additions and 112 deletions
|
@ -1,4 +1,4 @@
|
|||
use std::{borrow::Cow, path::Path};
|
||||
use std::{borrow::Cow, path::PathBuf};
|
||||
|
||||
use anyhow::{Result, bail};
|
||||
use async_trait::async_trait;
|
||||
|
@ -11,8 +11,6 @@ pub(crate) struct NodeLocator;
|
|||
|
||||
const TYPESCRIPT_RUNNER_VARIABLE: VariableName =
|
||||
VariableName::Custom(Cow::Borrowed("TYPESCRIPT_RUNNER"));
|
||||
const TYPESCRIPT_JEST_TASK_VARIABLE: VariableName =
|
||||
VariableName::Custom(Cow::Borrowed("TYPESCRIPT_JEST"));
|
||||
|
||||
#[async_trait]
|
||||
impl DapLocator for NodeLocator {
|
||||
|
@ -34,14 +32,21 @@ impl DapLocator for NodeLocator {
|
|||
return None;
|
||||
}
|
||||
let test_library = build_config.args.first()?;
|
||||
let program_path = Path::new("$ZED_WORKTREE_ROOT")
|
||||
let program_path_base: PathBuf = match test_library.as_str() {
|
||||
"jest" => "${ZED_CUSTOM_TYPESCRIPT_JEST_PACKAGE_PATH}".to_owned(),
|
||||
"mocha" => "${ZED_CUSTOM_TYPESCRIPT_MOCHA_PACKAGE_PATH}".to_owned(),
|
||||
"vitest" => "${ZED_CUSTOM_TYPESCRIPT_VITEST_PACKAGE_PATH}".to_owned(),
|
||||
"jasmine" => "${ZED_CUSTOM_TYPESCRIPT_JASMINE_PACKAGE_PATH}".to_owned(),
|
||||
_ => VariableName::WorktreeRoot.template_value(),
|
||||
}
|
||||
.into();
|
||||
|
||||
let program_path = program_path_base
|
||||
.join("node_modules")
|
||||
.join(".bin")
|
||||
.join(test_library);
|
||||
|
||||
let mut args = if test_library == "jest"
|
||||
|| test_library == &TYPESCRIPT_JEST_TASK_VARIABLE.template_value()
|
||||
{
|
||||
let mut args = if test_library == "jest" {
|
||||
vec!["--runInBand".to_owned()]
|
||||
} else {
|
||||
vec![]
|
||||
|
|
|
@ -278,7 +278,7 @@ impl language::LanguageToolchainStore for RemoteStore {
|
|||
}
|
||||
}
|
||||
|
||||
pub(crate) struct EmptyToolchainStore;
|
||||
pub struct EmptyToolchainStore;
|
||||
#[async_trait(?Send)]
|
||||
impl language::LanguageToolchainStore for EmptyToolchainStore {
|
||||
async fn active_toolchain(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue