mirror of
https://github.com/kbwo/testing-language-server.git
synced 2025-07-23 10:55:01 +00:00
list project files correctly
This commit is contained in:
parent
f9c054ebd3
commit
60e352f24f
6 changed files with 136 additions and 33 deletions
104
Cargo.lock
generated
104
Cargo.lock
generated
|
@ -77,6 +77,16 @@ version = "2.5.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1"
|
||||
|
||||
[[package]]
|
||||
name = "bstr"
|
||||
version = "1.9.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "05efc5cfd9110c8416e471df0e96702d58690178e206e61b7173706673c93706"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.0.96"
|
||||
|
@ -144,6 +154,25 @@ dependencies = [
|
|||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-deque"
|
||||
version = "0.8.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d"
|
||||
dependencies = [
|
||||
"crossbeam-epoch",
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-epoch"
|
||||
version = "0.9.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e"
|
||||
dependencies = [
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-utils"
|
||||
version = "0.8.19"
|
||||
|
@ -222,6 +251,30 @@ version = "0.3.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
|
||||
|
||||
[[package]]
|
||||
name = "globset"
|
||||
version = "0.4.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "57da3b9b5b85bd66f31093f8c408b90a74431672542466497dcbdfdc02034be1"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"bstr",
|
||||
"log",
|
||||
"regex-automata",
|
||||
"regex-syntax",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "globwalk"
|
||||
version = "0.9.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0bf760ebf69878d9fd8f110c89703d90ce35095324d1f1edcb595c63945ee757"
|
||||
dependencies = [
|
||||
"bitflags 2.5.0",
|
||||
"ignore",
|
||||
"walkdir",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "heck"
|
||||
version = "0.4.1"
|
||||
|
@ -244,6 +297,22 @@ dependencies = [
|
|||
"unicode-normalization",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ignore"
|
||||
version = "0.4.22"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b46810df39e66e925525d6e38ce1e7f6e1d208f72dc39757880fcb66e2c58af1"
|
||||
dependencies = [
|
||||
"crossbeam-deque",
|
||||
"globset",
|
||||
"log",
|
||||
"memchr",
|
||||
"regex-automata",
|
||||
"same-file",
|
||||
"walkdir",
|
||||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itoa"
|
||||
version = "1.0.11"
|
||||
|
@ -278,6 +347,12 @@ version = "0.4.13"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c"
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.22"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24"
|
||||
|
||||
[[package]]
|
||||
name = "lsp-types"
|
||||
version = "0.95.1"
|
||||
|
@ -416,6 +491,15 @@ version = "1.0.17"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1"
|
||||
|
||||
[[package]]
|
||||
name = "same-file"
|
||||
version = "1.0.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502"
|
||||
dependencies = [
|
||||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.198"
|
||||
|
@ -526,6 +610,7 @@ dependencies = [
|
|||
"clap",
|
||||
"dirs",
|
||||
"glob",
|
||||
"globwalk",
|
||||
"lsp-types",
|
||||
"once_cell",
|
||||
"regex",
|
||||
|
@ -791,12 +876,31 @@ version = "0.2.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a"
|
||||
|
||||
[[package]]
|
||||
name = "walkdir"
|
||||
version = "2.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b"
|
||||
dependencies = [
|
||||
"same-file",
|
||||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.11.0+wasi-snapshot-preview1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-util"
|
||||
version = "0.1.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b"
|
||||
dependencies = [
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.48.0"
|
||||
|
|
|
@ -46,3 +46,4 @@ clap = { workspace = true }
|
|||
once_cell = { workspace = true }
|
||||
strum = { workspace = true, features = ["derive"] }
|
||||
glob = { workspace = true }
|
||||
globwalk = "0.9.1"
|
||||
|
|
|
@ -8,7 +8,6 @@ use crate::spec::RunFileTestResultItem;
|
|||
use crate::spec::WorkspaceAnalysis;
|
||||
use crate::util::format_uri;
|
||||
use crate::util::send_stdout;
|
||||
use glob::glob;
|
||||
use glob::Pattern;
|
||||
use lsp_types::Diagnostic;
|
||||
use lsp_types::DiagnosticOptions;
|
||||
|
@ -130,7 +129,9 @@ impl TestingLS {
|
|||
|
||||
let value: Value = serde_json::from_str(&message)?;
|
||||
let method = &value["method"].as_str();
|
||||
tracing::info!("method={:#?}", method);
|
||||
let params = &value["params"];
|
||||
tracing::info!("params={:#?}", params);
|
||||
|
||||
if let Some(method) = method {
|
||||
match *method {
|
||||
|
@ -197,25 +198,25 @@ impl TestingLS {
|
|||
exclude_patterns: &[String],
|
||||
) -> Vec<String> {
|
||||
let mut result: Vec<String> = vec![];
|
||||
let base_dir = base_dir.to_string_lossy().to_string();
|
||||
|
||||
let exclude_pattern = exclude_patterns
|
||||
.iter()
|
||||
.filter_map(|exclude_pattern| {
|
||||
Pattern::new(&format!("!{base_dir}{exclude_pattern}")).ok()
|
||||
Pattern::new(base_dir.join(exclude_pattern).to_str().unwrap()).ok()
|
||||
})
|
||||
.collect::<Vec<Pattern>>();
|
||||
for include_pattern in include_patterns {
|
||||
let matched = glob(format!("{base_dir}{include_pattern}").as_str());
|
||||
if let Ok(entries) = matched {
|
||||
for path in entries.flatten() {
|
||||
let should_exclude = exclude_pattern
|
||||
.iter()
|
||||
.any(|exclude_pattern| exclude_pattern.matches(path.to_str().unwrap()));
|
||||
if !should_exclude {
|
||||
result.push(path.display().to_string());
|
||||
}
|
||||
}
|
||||
let base_dir = base_dir.to_str().unwrap();
|
||||
let entries = globwalk::GlobWalkerBuilder::from_patterns(base_dir, include_patterns)
|
||||
.follow_links(true)
|
||||
.build()
|
||||
.unwrap()
|
||||
.filter_map(Result::ok);
|
||||
for path in entries {
|
||||
let should_exclude = exclude_pattern
|
||||
.iter()
|
||||
.any(|exclude_pattern| exclude_pattern.matches(path.path().to_str().unwrap()));
|
||||
if !should_exclude {
|
||||
result.push(path.path().to_str().unwrap().to_owned());
|
||||
}
|
||||
}
|
||||
result
|
||||
|
@ -458,7 +459,7 @@ impl TestingLS {
|
|||
}))
|
||||
.unwrap();
|
||||
let progress_begin = WorkDoneProgressBegin {
|
||||
title: format!("Testing by adapter: {}", adapter.path),
|
||||
title: "Testing".to_string(),
|
||||
cancellable: Some(false),
|
||||
message: Some(format!("testing {} files ...", paths.len())),
|
||||
percentage: Some(0),
|
||||
|
@ -553,7 +554,6 @@ impl TestingLS {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::util::extension_from_url_str;
|
||||
use lsp_types::{Url, WorkspaceFolder};
|
||||
use std::collections::HashMap;
|
||||
|
||||
|
@ -636,18 +636,17 @@ mod tests {
|
|||
let files = TestingLS::project_files(
|
||||
&absolute_path_of_test_proj.clone(),
|
||||
&["/rust/src/lib.rs".to_string()],
|
||||
&["/rust/src/target/**/*".to_string()],
|
||||
&["/rust/target/**/*".to_string()],
|
||||
);
|
||||
let librs = absolute_path_of_test_proj.join("rust/src/lib.rs");
|
||||
assert_eq!(files, vec![librs.to_str().unwrap()]);
|
||||
let files = TestingLS::project_files(
|
||||
&absolute_path_of_test_proj.clone(),
|
||||
&["**/*.js".to_string()],
|
||||
&["**/node_modules/**/*".to_string()],
|
||||
&["jest/*.spec.js".to_string()],
|
||||
&["jest/another.spec.js".to_string()],
|
||||
);
|
||||
files.iter().for_each(|file| {
|
||||
assert_eq!(extension_from_url_str(file).unwrap(), ".js");
|
||||
});
|
||||
let test_file = absolute_path_of_test_proj.join("jest/index.spec.js");
|
||||
assert_eq!(files, vec![test_file.to_str().unwrap()]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -43,9 +43,9 @@ pub struct DetectWorkspaceArgs {
|
|||
pub extra: Vec<String>,
|
||||
}
|
||||
|
||||
pub(crate) type AdapterId = String;
|
||||
pub(crate) type FilePath = String;
|
||||
pub(crate) type WorkspaceFilePath = String;
|
||||
pub type AdapterId = String;
|
||||
pub type FilePath = String;
|
||||
pub type WorkspaceFilePath = String;
|
||||
|
||||
#[derive(Debug, Serialize, Clone)]
|
||||
pub struct WorkspaceAnalysis {
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
{
|
||||
"path": "testing-ls-adapter",
|
||||
"extra_args": ["--test-kind=cargo-test"],
|
||||
"include_patterns": ["/**/*.rs"],
|
||||
"include_patterns": ["/**/src/**/*.rs"],
|
||||
"exclude_patterns": ["/**/target/**"]
|
||||
}
|
||||
],
|
||||
|
@ -19,7 +19,7 @@
|
|||
"path": "testing-ls-adapter",
|
||||
"extra_args": ["--test-kind=jest"],
|
||||
"include_patterns": ["/**/*.js"],
|
||||
"exclude_patterns": ["/node_modules/**/*"]
|
||||
"exclude_patterns": ["/**/node_modules/**/*"]
|
||||
}
|
||||
],
|
||||
"go": [
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
describe("another", () => {
|
||||
|
||||
it("fail", () => {
|
||||
expect(1).toBe(0)
|
||||
})
|
||||
expect(1).toBe(0);
|
||||
});
|
||||
|
||||
it("pass", () => {
|
||||
expect(1).toBe(1)
|
||||
})
|
||||
})
|
||||
expect(1).toBe(1);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue