mirror of
https://github.com/kbwo/testing-language-server.git
synced 2025-08-03 23:28:14 +00:00
chore(adapter): add tracing logs
This commit is contained in:
parent
7935caf4b3
commit
3d01eef6b1
8 changed files with 40 additions and 19 deletions
|
@ -11,7 +11,7 @@ use testing_language_server::spec::DiscoverResultItem;
|
|||
|
||||
use crate::model::Runner;
|
||||
|
||||
use super::util::detect_workspaces_from_file_paths;
|
||||
use super::util::detect_workspaces_from_file_list;
|
||||
use super::util::discover_rust_tests;
|
||||
use super::util::parse_cargo_diagnostics;
|
||||
use super::util::write_result_log;
|
||||
|
@ -25,13 +25,14 @@ fn parse_diagnostics(
|
|||
}
|
||||
|
||||
fn detect_workspaces(file_paths: &[String]) -> DetectWorkspaceResult {
|
||||
detect_workspaces_from_file_paths(file_paths, &["Cargo.toml".to_string()])
|
||||
detect_workspaces_from_file_list(file_paths, &["Cargo.toml".to_string()])
|
||||
}
|
||||
|
||||
#[derive(Eq, PartialEq, Hash, Debug)]
|
||||
pub struct CargoNextestRunner;
|
||||
|
||||
impl Runner for CargoNextestRunner {
|
||||
#[tracing::instrument(skip(self))]
|
||||
fn discover(&self, args: testing_language_server::spec::DiscoverArgs) -> Result<(), LSError> {
|
||||
let file_paths = args.file_paths;
|
||||
let mut discover_results: DiscoverResult = vec![];
|
||||
|
@ -47,6 +48,7 @@ impl Runner for CargoNextestRunner {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip(self))]
|
||||
fn run_file_test(
|
||||
&self,
|
||||
args: testing_language_server::spec::RunFileTestArgs,
|
||||
|
@ -98,6 +100,7 @@ impl Runner for CargoNextestRunner {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip(self))]
|
||||
fn detect_workspaces(
|
||||
&self,
|
||||
args: testing_language_server::spec::DetectWorkspaceArgs,
|
||||
|
|
|
@ -11,7 +11,7 @@ use testing_language_server::spec::DiscoverResultItem;
|
|||
|
||||
use crate::model::Runner;
|
||||
|
||||
use super::util::detect_workspaces_from_file_paths;
|
||||
use super::util::detect_workspaces_from_file_list;
|
||||
use super::util::discover_rust_tests;
|
||||
use super::util::parse_cargo_diagnostics;
|
||||
use super::util::write_result_log;
|
||||
|
@ -25,13 +25,14 @@ fn parse_diagnostics(
|
|||
}
|
||||
|
||||
fn detect_workspaces(file_paths: &[String]) -> DetectWorkspaceResult {
|
||||
detect_workspaces_from_file_paths(file_paths, &["Cargo.toml".to_string()])
|
||||
detect_workspaces_from_file_list(file_paths, &["Cargo.toml".to_string()])
|
||||
}
|
||||
|
||||
#[derive(Eq, PartialEq, Hash, Debug)]
|
||||
pub struct CargoTestRunner;
|
||||
|
||||
impl Runner for CargoTestRunner {
|
||||
#[tracing::instrument(skip(self))]
|
||||
fn discover(&self, args: testing_language_server::spec::DiscoverArgs) -> Result<(), LSError> {
|
||||
let file_paths = args.file_paths;
|
||||
let mut discover_results: DiscoverResult = vec![];
|
||||
|
@ -47,6 +48,7 @@ impl Runner for CargoTestRunner {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip(self))]
|
||||
fn run_file_test(
|
||||
&self,
|
||||
args: testing_language_server::spec::RunFileTestArgs,
|
||||
|
@ -90,6 +92,7 @@ impl Runner for CargoTestRunner {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip(self))]
|
||||
fn detect_workspaces(
|
||||
&self,
|
||||
args: testing_language_server::spec::DetectWorkspaceArgs,
|
||||
|
|
|
@ -21,7 +21,7 @@ use testing_language_server::spec::TestItem;
|
|||
use crate::model::Runner;
|
||||
|
||||
use super::util::clean_ansi;
|
||||
use super::util::detect_workspaces_from_file_paths;
|
||||
use super::util::detect_workspaces_from_file_list;
|
||||
use super::util::discover_with_treesitter;
|
||||
use super::util::write_result_log;
|
||||
use super::util::MAX_CHAR_LENGTH;
|
||||
|
@ -96,7 +96,7 @@ fn parse_diagnostics(
|
|||
}
|
||||
|
||||
fn detect_workspaces(file_paths: Vec<String>) -> DetectWorkspaceResult {
|
||||
detect_workspaces_from_file_paths(&file_paths, &["deno.json".to_string()])
|
||||
detect_workspaces_from_file_list(&file_paths, &["deno.json".to_string()])
|
||||
}
|
||||
|
||||
fn discover(file_path: &str) -> Result<Vec<TestItem>, LSError> {
|
||||
|
@ -158,6 +158,7 @@ fn discover(file_path: &str) -> Result<Vec<TestItem>, LSError> {
|
|||
pub struct DenoRunner;
|
||||
|
||||
impl Runner for DenoRunner {
|
||||
#[tracing::instrument(skip(self))]
|
||||
fn discover(&self, args: testing_language_server::spec::DiscoverArgs) -> Result<(), LSError> {
|
||||
let file_paths = args.file_paths;
|
||||
let mut discover_results: DiscoverResult = vec![];
|
||||
|
@ -171,6 +172,7 @@ impl Runner for DenoRunner {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip(self))]
|
||||
fn run_file_test(
|
||||
&self,
|
||||
args: testing_language_server::spec::RunFileTestArgs,
|
||||
|
@ -198,6 +200,7 @@ impl Runner for DenoRunner {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip(self))]
|
||||
fn detect_workspaces(
|
||||
&self,
|
||||
args: testing_language_server::spec::DetectWorkspaceArgs,
|
||||
|
|
|
@ -18,7 +18,7 @@ use testing_language_server::spec::RunFileTestResult;
|
|||
use testing_language_server::spec::RunFileTestResultItem;
|
||||
use testing_language_server::spec::TestItem;
|
||||
|
||||
use super::util::detect_workspaces_from_file_paths;
|
||||
use super::util::detect_workspaces_from_file_list;
|
||||
use super::util::discover_with_treesitter;
|
||||
use super::util::write_result_log;
|
||||
use super::util::MAX_CHAR_LENGTH;
|
||||
|
@ -226,6 +226,7 @@ fn discover(file_path: &str) -> Result<Vec<TestItem>, LSError> {
|
|||
#[derive(Eq, PartialEq, Hash, Debug)]
|
||||
pub struct GoTestRunner;
|
||||
impl Runner for GoTestRunner {
|
||||
#[tracing::instrument(skip(self))]
|
||||
fn discover(
|
||||
&self,
|
||||
args: testing_language_server::spec::DiscoverArgs,
|
||||
|
@ -244,6 +245,7 @@ impl Runner for GoTestRunner {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip(self))]
|
||||
fn run_file_test(
|
||||
&self,
|
||||
args: testing_language_server::spec::RunFileTestArgs,
|
||||
|
@ -273,11 +275,12 @@ impl Runner for GoTestRunner {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip(self))]
|
||||
fn detect_workspaces(
|
||||
&self,
|
||||
args: testing_language_server::spec::DetectWorkspaceArgs,
|
||||
) -> Result<(), testing_language_server::error::LSError> {
|
||||
send_stdout(&detect_workspaces_from_file_paths(
|
||||
send_stdout(&detect_workspaces_from_file_list(
|
||||
&args.file_paths,
|
||||
&["go.mod".to_string()],
|
||||
))?;
|
||||
|
|
|
@ -16,7 +16,7 @@ use testing_language_server::spec::TestItem;
|
|||
use crate::model::Runner;
|
||||
|
||||
use super::util::clean_ansi;
|
||||
use super::util::detect_workspaces_from_file_paths;
|
||||
use super::util::detect_workspaces_from_file_list;
|
||||
use super::util::discover_with_treesitter;
|
||||
use super::util::LOG_LOCATION;
|
||||
use super::util::MAX_CHAR_LENGTH;
|
||||
|
@ -74,7 +74,7 @@ fn parse_diagnostics(
|
|||
}
|
||||
|
||||
fn detect_workspaces(file_paths: Vec<String>) -> DetectWorkspaceResult {
|
||||
detect_workspaces_from_file_paths(&file_paths, &["package.json".to_string()])
|
||||
detect_workspaces_from_file_list(&file_paths, &["package.json".to_string()])
|
||||
}
|
||||
|
||||
fn discover(file_path: &str) -> Result<Vec<TestItem>, LSError> {
|
||||
|
@ -156,6 +156,7 @@ fn discover(file_path: &str) -> Result<Vec<TestItem>, LSError> {
|
|||
pub struct JestRunner;
|
||||
|
||||
impl Runner for JestRunner {
|
||||
#[tracing::instrument(skip(self))]
|
||||
fn discover(&self, args: testing_language_server::spec::DiscoverArgs) -> Result<(), LSError> {
|
||||
let file_paths = args.file_paths;
|
||||
let mut discover_results: DiscoverResult = vec![];
|
||||
|
@ -169,6 +170,7 @@ impl Runner for JestRunner {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip(self))]
|
||||
fn run_file_test(
|
||||
&self,
|
||||
args: testing_language_server::spec::RunFileTestArgs,
|
||||
|
@ -195,6 +197,7 @@ impl Runner for JestRunner {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip(self))]
|
||||
fn detect_workspaces(
|
||||
&self,
|
||||
args: testing_language_server::spec::DetectWorkspaceArgs,
|
||||
|
|
|
@ -12,7 +12,7 @@ use xml::reader::{ParserConfig, XmlEvent};
|
|||
use crate::model::Runner;
|
||||
|
||||
use super::util::{
|
||||
detect_workspaces_from_file_paths, discover_with_treesitter, send_stdout, LOG_LOCATION,
|
||||
detect_workspaces_from_file_list, discover_with_treesitter, send_stdout, LOG_LOCATION,
|
||||
MAX_CHAR_LENGTH,
|
||||
};
|
||||
|
||||
|
@ -47,7 +47,7 @@ impl Into<RunFileTestResultItem> for ResultFromXml {
|
|||
}
|
||||
|
||||
fn detect_workspaces(file_paths: Vec<String>) -> DetectWorkspaceResult {
|
||||
detect_workspaces_from_file_paths(&file_paths, &["composer.json".to_string()])
|
||||
detect_workspaces_from_file_list(&file_paths, &["composer.json".to_string()])
|
||||
}
|
||||
|
||||
fn get_result_from_characters(characters: &str) -> Result<ResultFromXml, anyhow::Error> {
|
||||
|
@ -152,6 +152,7 @@ fn discover(file_path: &str) -> Result<Vec<TestItem>, LSError> {
|
|||
pub struct PhpunitRunner;
|
||||
|
||||
impl Runner for PhpunitRunner {
|
||||
#[tracing::instrument(skip(self))]
|
||||
fn discover(&self, args: testing_language_server::spec::DiscoverArgs) -> Result<(), LSError> {
|
||||
let file_paths = args.file_paths;
|
||||
let mut discover_results: DiscoverResult = vec![];
|
||||
|
@ -165,6 +166,7 @@ impl Runner for PhpunitRunner {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip(self))]
|
||||
fn run_file_test(
|
||||
&self,
|
||||
args: testing_language_server::spec::RunFileTestArgs,
|
||||
|
@ -216,6 +218,7 @@ impl Runner for PhpunitRunner {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip(self))]
|
||||
fn detect_workspaces(
|
||||
&self,
|
||||
args: testing_language_server::spec::DetectWorkspaceArgs,
|
||||
|
|
|
@ -21,7 +21,7 @@ pub static LOG_LOCATION: LazyLock<PathBuf> = LazyLock::new(|| {
|
|||
pub const MAX_CHAR_LENGTH: u32 = 10000;
|
||||
|
||||
/// determine if a particular file is the root of workspace based on whether it is in the same directory
|
||||
pub fn detect_workspace_from_file(file_path: PathBuf, file_names: &[String]) -> Option<String> {
|
||||
fn detect_workspace_from_file(file_path: PathBuf, file_names: &[String]) -> Option<String> {
|
||||
let parent = file_path.parent();
|
||||
if let Some(parent) = parent {
|
||||
if file_names
|
||||
|
@ -37,7 +37,7 @@ pub fn detect_workspace_from_file(file_path: PathBuf, file_names: &[String]) ->
|
|||
}
|
||||
}
|
||||
|
||||
pub fn detect_workspaces_from_file_paths(
|
||||
pub fn detect_workspaces_from_file_list(
|
||||
target_file_paths: &[String],
|
||||
file_names: &[String],
|
||||
) -> HashMap<String, Vec<String>> {
|
||||
|
@ -54,9 +54,9 @@ pub fn detect_workspaces_from_file_paths(
|
|||
.or_default()
|
||||
.push(file_path.clone());
|
||||
}
|
||||
// Push the file path to the found workspace even if the existing_workspace becomes Some.
|
||||
// In some cases, the simple method of finding a workspace, such as the relationship
|
||||
// between the project root and the adapter crate in this repository, does not work.
|
||||
// Push the file path to the found workspace even if existing_workspace becomes Some.
|
||||
// In some cases, a simple way to find a workspace,
|
||||
// such as the relationship between the project root and the adapter crate in this repository, may not work.
|
||||
let workspace =
|
||||
detect_workspace_from_file(PathBuf::from_str(&file_path).unwrap(), file_names);
|
||||
if let Some(workspace) = workspace {
|
||||
|
|
|
@ -15,7 +15,7 @@ use testing_language_server::{
|
|||
use crate::model::Runner;
|
||||
|
||||
use super::util::{
|
||||
clean_ansi, detect_workspaces_from_file_paths, discover_with_treesitter, send_stdout,
|
||||
clean_ansi, detect_workspaces_from_file_list, discover_with_treesitter, send_stdout,
|
||||
LOG_LOCATION, MAX_CHAR_LENGTH,
|
||||
};
|
||||
|
||||
|
@ -131,6 +131,7 @@ fn parse_diagnostics(
|
|||
}
|
||||
|
||||
impl Runner for VitestRunner {
|
||||
#[tracing::instrument(skip(self))]
|
||||
fn discover(&self, args: testing_language_server::spec::DiscoverArgs) -> Result<(), LSError> {
|
||||
let file_paths = args.file_paths;
|
||||
let mut discover_results: DiscoverResult = vec![];
|
||||
|
@ -146,6 +147,7 @@ impl Runner for VitestRunner {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip(self))]
|
||||
fn run_file_test(
|
||||
&self,
|
||||
args: testing_language_server::spec::RunFileTestArgs,
|
||||
|
@ -170,11 +172,12 @@ impl Runner for VitestRunner {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip(self))]
|
||||
fn detect_workspaces(
|
||||
&self,
|
||||
args: testing_language_server::spec::DetectWorkspaceArgs,
|
||||
) -> Result<(), LSError> {
|
||||
send_stdout(&detect_workspaces_from_file_paths(
|
||||
send_stdout(&detect_workspaces_from_file_list(
|
||||
&args.file_paths,
|
||||
&[
|
||||
"package.json".to_string(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue