refactor: rename directory

This commit is contained in:
kbwo 2024-07-15 19:13:19 +09:00
parent 4782784122
commit 1d6dd6623e
41 changed files with 54 additions and 67 deletions

View file

@ -7,7 +7,7 @@
"path": "testing-ls-adapter",
"extra_args": ["--test-kind=cargo-test", "--workspace"],
"include_patterns": ["/**/*.rs"],
"exclude_patterns": ["/test_proj/**/*"],
"exclude_patterns": ["/demo/**/*"],
"workspace_dir": "."
}
]

View file

@ -8,7 +8,7 @@ license = "MIT"
[workspace]
members = [ "crates/adapter"]
exclude = ["test_proj"]
exclude = ["demo"]
[[bin]]
name = "testing-language-server"

View file

@ -323,7 +323,7 @@ note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
#[test]
fn test_discover() {
let file_path = "../../test_proj/rust/src/lib.rs";
let file_path = "../../demo/rust/src/lib.rs";
discover(file_path).unwrap();
}
@ -332,16 +332,16 @@ note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
let current_dir = std::env::current_dir().unwrap();
let librs = current_dir.join("src/lib.rs");
let mainrs = current_dir.join("src/main.rs");
let absolute_path_of_test_proj = current_dir.join("../../test_proj/rust");
let test_proj_librs = absolute_path_of_test_proj.join("src/lib.rs");
let file_paths: Vec<String> = [librs, mainrs, test_proj_librs]
let absolute_path_of_demo = current_dir.join("../../demo/rust");
let demo_librs = absolute_path_of_demo.join("src/lib.rs");
let file_paths: Vec<String> = [librs, mainrs, demo_librs]
.iter()
.map(|file_path| file_path.to_str().unwrap().to_string())
.collect();
let workspaces = detect_workspaces(&file_paths);
assert_eq!(workspaces.len(), 2);
assert!(workspaces.contains_key(absolute_path_of_test_proj.to_str().unwrap()));
assert!(workspaces.contains_key(absolute_path_of_demo.to_str().unwrap()));
assert!(workspaces.contains_key(current_dir.to_str().unwrap()));
}
}

View file

@ -381,7 +381,7 @@ mod tests {
#[test]
fn test_discover() {
let file_path = "../../test_proj/go/cases_test.go";
let file_path = "../../demo/go/cases_test.go";
let test_items = discover(file_path).unwrap();
assert!(!test_items.is_empty());
}

View file

@ -289,13 +289,13 @@ mod tests {
fn test_parse_diagnostics() {
let test_result = std::env::current_dir()
.unwrap()
.join("../../test_proj/jest/output.json");
.join("../../demo/jest/output.json");
let test_result = std::fs::read_to_string(test_result).unwrap();
let diagnostics = parse_diagnostics(
&test_result,
vec![
"/absolute_path/test_proj/jest/index.spec.js".to_string(),
"/absolute_path/test_proj/jest/another.spec.js".to_string(),
"/absolute_path/demo/jest/index.spec.js".to_string(),
"/absolute_path/demo/jest/another.spec.js".to_string(),
],
)
.unwrap();
@ -305,22 +305,22 @@ mod tests {
#[test]
fn test_detect_workspace() {
let current_dir = std::env::current_dir().unwrap();
let absolute_path_of_test_proj = current_dir.join("../../test_proj/jest");
let test_proj_indexjs = absolute_path_of_test_proj.join("index.spec.js");
let file_paths: Vec<String> = [test_proj_indexjs]
let absolute_path_of_demo = current_dir.join("../../demo/jest");
let demo_indexjs = absolute_path_of_demo.join("index.spec.js");
let file_paths: Vec<String> = [demo_indexjs]
.iter()
.map(|file_path| file_path.to_str().unwrap().to_string())
.collect();
let detect_result = detect_workspaces(file_paths);
assert_eq!(detect_result.len(), 1);
detect_result.iter().for_each(|(workspace, _)| {
assert_eq!(workspace, absolute_path_of_test_proj.to_str().unwrap());
assert_eq!(workspace, absolute_path_of_demo.to_str().unwrap());
});
}
#[test]
fn test_discover() {
let file_path = "../../test_proj/jest/index.spec.js";
let file_path = "../../demo/jest/index.spec.js";
let test_items = discover(file_path).unwrap();
assert_eq!(test_items.len(), 1);
assert_eq!(

View file

@ -270,7 +270,7 @@ mod tests {
#[test]
fn test_discover() {
let file_path = "../../test_proj/vitest/basic.test.ts";
let file_path = "../../demo/vitest/basic.test.ts";
let test_items = discover(file_path).unwrap();
assert_eq!(test_items.len(), 2);
assert_eq!(

View file

@ -1,4 +1,4 @@
# test_proj
# demo
To install dependencies:

View file

@ -32,9 +32,7 @@
{
"assertionResults": [
{
"ancestorTitles": [
"index"
],
"ancestorTitles": ["index"],
"duration": 3,
"failureDetails": [
{
@ -48,7 +46,7 @@
}
],
"failureMessages": [
"Error: \u001b[2mexpect(\u001b[22m\u001b[31mreceived\u001b[39m\u001b[2m).\u001b[22mtoBe\u001b[2m(\u001b[22m\u001b[32mexpected\u001b[39m\u001b[2m) // Object.is equality\u001b[22m\n\nExpected: \u001b[32m0\u001b[39m\nReceived: \u001b[31m1\u001b[39m\n at Object.toBe (/absolute_path/test_proj/jest/index.spec.js:4:15)\n at Promise.then.completed (/absolute_path/test_proj/jest/node_modules/jest-circus/build/utils.js:298:28)\n at new Promise (<anonymous>)\n at callAsyncCircusFn (/absolute_path/test_proj/jest/node_modules/jest-circus/build/utils.js:231:10)\n at _callCircusTest (/absolute_path/test_proj/jest/node_modules/jest-circus/build/run.js:316:40)\n at _runTest (/absolute_path/test_proj/jest/node_modules/jest-circus/build/run.js:252:3)\n at _runTestsForDescribeBlock (/absolute_path/test_proj/jest/node_modules/jest-circus/build/run.js:126:9)\n at _runTestsForDescribeBlock (/absolute_path/test_proj/jest/node_modules/jest-circus/build/run.js:121:9)\n at run (/absolute_path/test_proj/jest/node_modules/jest-circus/build/run.js:71:3)\n at runAndTransformResultsToJestFormat (/absolute_path/test_proj/jest/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:122:21)\n at jestAdapter (/absolute_path/test_proj/jest/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:79:19)\n at runTestInternal (/absolute_path/test_proj/jest/node_modules/jest-runner/build/runTest.js:367:16)\n at runTest (/absolute_path/test_proj/jest/node_modules/jest-runner/build/runTest.js:444:34)"
"Error: \u001b[2mexpect(\u001b[22m\u001b[31mreceived\u001b[39m\u001b[2m).\u001b[22mtoBe\u001b[2m(\u001b[22m\u001b[32mexpected\u001b[39m\u001b[2m) // Object.is equality\u001b[22m\n\nExpected: \u001b[32m0\u001b[39m\nReceived: \u001b[31m1\u001b[39m\n at Object.toBe (/absolute_path/demo/jest/index.spec.js:4:15)\n at Promise.then.completed (/absolute_path/demo/jest/node_modules/jest-circus/build/utils.js:298:28)\n at new Promise (<anonymous>)\n at callAsyncCircusFn (/absolute_path/demo/jest/node_modules/jest-circus/build/utils.js:231:10)\n at _callCircusTest (/absolute_path/demo/jest/node_modules/jest-circus/build/run.js:316:40)\n at _runTest (/absolute_path/demo/jest/node_modules/jest-circus/build/run.js:252:3)\n at _runTestsForDescribeBlock (/absolute_path/demo/jest/node_modules/jest-circus/build/run.js:126:9)\n at _runTestsForDescribeBlock (/absolute_path/demo/jest/node_modules/jest-circus/build/run.js:121:9)\n at run (/absolute_path/demo/jest/node_modules/jest-circus/build/run.js:71:3)\n at runAndTransformResultsToJestFormat (/absolute_path/demo/jest/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:122:21)\n at jestAdapter (/absolute_path/demo/jest/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:79:19)\n at runTestInternal (/absolute_path/demo/jest/node_modules/jest-runner/build/runTest.js:367:16)\n at runTest (/absolute_path/demo/jest/node_modules/jest-runner/build/runTest.js:444:34)"
],
"fullName": "index fail",
"invocations": 1,
@ -64,7 +62,7 @@
],
"endTime": 1714484637874,
"message": "\u001b[1m\u001b[31m \u001b[1m● \u001b[22m\u001b[1mindex fail\u001b[39m\u001b[22m\n\n \u001b[2mexpect(\u001b[22m\u001b[31mreceived\u001b[39m\u001b[2m).\u001b[22mtoBe\u001b[2m(\u001b[22m\u001b[32mexpected\u001b[39m\u001b[2m) // Object.is equality\u001b[22m\n\n Expected: \u001b[32m0\u001b[39m\n Received: \u001b[31m1\u001b[39m\n\u001b[2m\u001b[22m\n\u001b[2m \u001b[0m \u001b[90m 2 |\u001b[39m\u001b[22m\n\u001b[2m \u001b[90m 3 |\u001b[39m it(\u001b[32m\"fail\"\u001b[39m\u001b[33m,\u001b[39m () \u001b[33m=>\u001b[39m {\u001b[22m\n\u001b[2m \u001b[31m\u001b[1m>\u001b[22m\u001b[2m\u001b[39m\u001b[90m 4 |\u001b[39m expect(\u001b[35m1\u001b[39m)\u001b[33m.\u001b[39mtoBe(\u001b[35m0\u001b[39m)\u001b[22m\n\u001b[2m \u001b[90m |\u001b[39m \u001b[31m\u001b[1m^\u001b[22m\u001b[2m\u001b[39m\u001b[22m\n\u001b[2m \u001b[90m 5 |\u001b[39m })\u001b[22m\n\u001b[2m \u001b[90m 6 |\u001b[39m\u001b[22m\n\u001b[2m \u001b[90m 7 |\u001b[39m })\u001b[0m\u001b[22m\n\u001b[2m\u001b[22m\n\u001b[2m \u001b[2mat Object.toBe (\u001b[22m\u001b[2m\u001b[0m\u001b[36mindex.spec.js\u001b[39m\u001b[0m\u001b[2m:4:15)\u001b[22m\u001b[2m\u001b[22m\n",
"name": "/absolute_path/test_proj/jest/index.spec.js",
"name": "/absolute_path/demo/jest/index.spec.js",
"startTime": 1714484637684,
"status": "failed",
"summary": ""
@ -72,9 +70,7 @@
{
"assertionResults": [
{
"ancestorTitles": [
"another"
],
"ancestorTitles": ["another"],
"duration": 2,
"failureDetails": [
{
@ -88,7 +84,7 @@
}
],
"failureMessages": [
"Error: \u001b[2mexpect(\u001b[22m\u001b[31mreceived\u001b[39m\u001b[2m).\u001b[22mtoBe\u001b[2m(\u001b[22m\u001b[32mexpected\u001b[39m\u001b[2m) // Object.is equality\u001b[22m\n\nExpected: \u001b[32m0\u001b[39m\nReceived: \u001b[31m1\u001b[39m\n at Object.toBe (/absolute_path/test_proj/jest/another.spec.js:4:15)\n at Promise.then.completed (/absolute_path/test_proj/jest/node_modules/jest-circus/build/utils.js:298:28)\n at new Promise (<anonymous>)\n at callAsyncCircusFn (/absolute_path/test_proj/jest/node_modules/jest-circus/build/utils.js:231:10)\n at _callCircusTest (/absolute_path/test_proj/jest/node_modules/jest-circus/build/run.js:316:40)\n at _runTest (/absolute_path/test_proj/jest/node_modules/jest-circus/build/run.js:252:3)\n at _runTestsForDescribeBlock (/absolute_path/test_proj/jest/node_modules/jest-circus/build/run.js:126:9)\n at _runTestsForDescribeBlock (/absolute_path/test_proj/jest/node_modules/jest-circus/build/run.js:121:9)\n at run (/absolute_path/test_proj/jest/node_modules/jest-circus/build/run.js:71:3)\n at runAndTransformResultsToJestFormat (/absolute_path/test_proj/jest/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:122:21)\n at jestAdapter (/absolute_path/test_proj/jest/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:79:19)\n at runTestInternal (/absolute_path/test_proj/jest/node_modules/jest-runner/build/runTest.js:367:16)\n at runTest (/absolute_path/test_proj/jest/node_modules/jest-runner/build/runTest.js:444:34)"
"Error: \u001b[2mexpect(\u001b[22m\u001b[31mreceived\u001b[39m\u001b[2m).\u001b[22mtoBe\u001b[2m(\u001b[22m\u001b[32mexpected\u001b[39m\u001b[2m) // Object.is equality\u001b[22m\n\nExpected: \u001b[32m0\u001b[39m\nReceived: \u001b[31m1\u001b[39m\n at Object.toBe (/absolute_path/demo/jest/another.spec.js:4:15)\n at Promise.then.completed (/absolute_path/demo/jest/node_modules/jest-circus/build/utils.js:298:28)\n at new Promise (<anonymous>)\n at callAsyncCircusFn (/absolute_path/demo/jest/node_modules/jest-circus/build/utils.js:231:10)\n at _callCircusTest (/absolute_path/demo/jest/node_modules/jest-circus/build/run.js:316:40)\n at _runTest (/absolute_path/demo/jest/node_modules/jest-circus/build/run.js:252:3)\n at _runTestsForDescribeBlock (/absolute_path/demo/jest/node_modules/jest-circus/build/run.js:126:9)\n at _runTestsForDescribeBlock (/absolute_path/demo/jest/node_modules/jest-circus/build/run.js:121:9)\n at run (/absolute_path/demo/jest/node_modules/jest-circus/build/run.js:71:3)\n at runAndTransformResultsToJestFormat (/absolute_path/demo/jest/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:122:21)\n at jestAdapter (/absolute_path/demo/jest/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:79:19)\n at runTestInternal (/absolute_path/demo/jest/node_modules/jest-runner/build/runTest.js:367:16)\n at runTest (/absolute_path/demo/jest/node_modules/jest-runner/build/runTest.js:444:34)"
],
"fullName": "another fail",
"invocations": 1,
@ -102,9 +98,7 @@
"title": "fail"
},
{
"ancestorTitles": [
"another"
],
"ancestorTitles": ["another"],
"duration": 1,
"failureDetails": [],
"failureMessages": [],
@ -122,7 +116,7 @@
],
"endTime": 1714484637974,
"message": "\u001b[1m\u001b[31m \u001b[1m● \u001b[22m\u001b[1manother fail\u001b[39m\u001b[22m\n\n \u001b[2mexpect(\u001b[22m\u001b[31mreceived\u001b[39m\u001b[2m).\u001b[22mtoBe\u001b[2m(\u001b[22m\u001b[32mexpected\u001b[39m\u001b[2m) // Object.is equality\u001b[22m\n\n Expected: \u001b[32m0\u001b[39m\n Received: \u001b[31m1\u001b[39m\n\u001b[2m\u001b[22m\n\u001b[2m \u001b[0m \u001b[90m 2 |\u001b[39m\u001b[22m\n\u001b[2m \u001b[90m 3 |\u001b[39m it(\u001b[32m\"fail\"\u001b[39m\u001b[33m,\u001b[39m () \u001b[33m=>\u001b[39m {\u001b[22m\n\u001b[2m \u001b[31m\u001b[1m>\u001b[22m\u001b[2m\u001b[39m\u001b[90m 4 |\u001b[39m expect(\u001b[35m1\u001b[39m)\u001b[33m.\u001b[39mtoBe(\u001b[35m0\u001b[39m)\u001b[22m\n\u001b[2m \u001b[90m |\u001b[39m \u001b[31m\u001b[1m^\u001b[22m\u001b[2m\u001b[39m\u001b[22m\n\u001b[2m \u001b[90m 5 |\u001b[39m })\u001b[22m\n\u001b[2m \u001b[90m 6 |\u001b[39m\u001b[22m\n\u001b[2m \u001b[90m 7 |\u001b[39m it(\u001b[32m\"pass\"\u001b[39m\u001b[33m,\u001b[39m () \u001b[33m=>\u001b[39m {\u001b[0m\u001b[22m\n\u001b[2m\u001b[22m\n\u001b[2m \u001b[2mat Object.toBe (\u001b[22m\u001b[2m\u001b[0m\u001b[36manother.spec.js\u001b[39m\u001b[0m\u001b[2m:4:15)\u001b[22m\u001b[2m\u001b[22m\n",
"name": "/absolute_path/test_proj/jest/another.spec.js",
"name": "/absolute_path/demo/jest/another.spec.js",
"startTime": 1714484637879,
"status": "failed",
"summary": ""

View file

@ -1,5 +1,5 @@
{
"name": "test_proj",
"name": "demo",
"module": "index.js",
"type": "module",
"devDependencies": {
@ -10,4 +10,4 @@
"peerDependencies": {
"typescript": "^5.0.0"
}
}
}

View file

@ -62,6 +62,13 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "demo"
version = "0.1.0"
dependencies = [
"tokio",
]
[[package]]
name = "gimli"
version = "0.28.1"
@ -239,13 +246,6 @@ dependencies = [
"unicode-ident",
]
[[package]]
name = "test_proj"
version = "0.1.0"
dependencies = [
"tokio",
]
[[package]]
name = "tokio"
version = "1.37.0"

View file

@ -1,5 +1,5 @@
[package]
name = "test_proj"
name = "demo"
version = "0.1.0"
edition = "2021"

View file

@ -577,12 +577,12 @@ mod tests {
#[test]
fn test_check_file() {
let abs_path_of_test_proj = std::env::current_dir().unwrap().join("test_proj/rust");
let abs_path_of_demo = std::env::current_dir().unwrap().join("demo/rust");
let mut server = TestingLS {
initialize_params: InitializeParams {
workspace_folders: Some(vec![WorkspaceFolder {
uri: Url::from_file_path(&abs_path_of_test_proj).unwrap(),
name: "test_proj".to_string(),
uri: Url::from_file_path(&abs_path_of_demo).unwrap(),
name: "demo".to_string(),
}]),
..InitializeParams::default()
},
@ -591,13 +591,13 @@ mod tests {
},
workspaces_cache: Vec::new(),
};
let librs = abs_path_of_test_proj.join("lib.rs");
let librs = abs_path_of_demo.join("lib.rs");
server.check_file(librs.to_str().unwrap(), true).unwrap();
}
#[test]
fn test_check_workspace() {
let abs_path_of_test_proj = std::env::current_dir().unwrap().join("test_proj/rust");
let abs_path_of_demo = std::env::current_dir().unwrap().join("demo/rust");
let abs_path_of_rust_adapter = std::env::current_dir()
.unwrap()
.join("target/debug/testing-ls-adapter");
@ -613,8 +613,8 @@ mod tests {
let mut server = TestingLS {
initialize_params: InitializeParams {
workspace_folders: Some(vec![WorkspaceFolder {
uri: Url::from_file_path(abs_path_of_test_proj.clone()).unwrap(),
name: "test_proj".to_string(),
uri: Url::from_file_path(abs_path_of_demo.clone()).unwrap(),
name: "demo".to_string(),
}]),
..InitializeParams::default()
},
@ -634,7 +634,7 @@ mod tests {
.workspaces
.iter()
.for_each(|(workspace, paths)| {
assert_eq!(workspace, abs_path_of_test_proj.to_str().unwrap());
assert_eq!(workspace, abs_path_of_demo.to_str().unwrap());
paths.iter().for_each(|path| {
assert!(path.contains("rust/src"));
});
@ -644,20 +644,20 @@ mod tests {
#[test]
fn project_files_are_filtered_by_extension() {
let absolute_path_of_test_proj = std::env::current_dir().unwrap().join("test_proj");
let absolute_path_of_demo = std::env::current_dir().unwrap().join("demo");
let files = TestingLS::project_files(
&absolute_path_of_test_proj.clone(),
&absolute_path_of_demo.clone(),
&["/rust/src/lib.rs".to_string()],
&["/rust/target/**/*".to_string()],
);
let librs = absolute_path_of_test_proj.join("rust/src/lib.rs");
let librs = absolute_path_of_demo.join("rust/src/lib.rs");
assert_eq!(files, vec![librs.to_str().unwrap()]);
let files = TestingLS::project_files(
&absolute_path_of_test_proj.clone(),
&absolute_path_of_demo.clone(),
&["jest/*.spec.js".to_string()],
&["jest/another.spec.js".to_string()],
);
let test_file = absolute_path_of_test_proj.join("jest/index.spec.js");
let test_file = absolute_path_of_demo.join("jest/index.spec.js");
assert_eq!(files, vec![test_file.to_str().unwrap()]);
}
@ -673,18 +673,15 @@ mod tests {
extra_args: vec!["--invalid-arg".to_string()],
..Default::default()
};
let abs_path_of_test_proj = std::env::current_dir().unwrap().join("test_proj/rust");
let files = TestingLS::project_files(
&abs_path_of_test_proj.clone(),
&["/**/*.rs".to_string()],
&[],
);
let abs_path_of_demo = std::env::current_dir().unwrap().join("demo/rust");
let files =
TestingLS::project_files(&abs_path_of_demo.clone(), &["/**/*.rs".to_string()], &[]);
let server = TestingLS {
initialize_params: InitializeParams {
workspace_folders: Some(vec![WorkspaceFolder {
uri: Url::from_file_path(&abs_path_of_test_proj).unwrap(),
name: "test_proj".to_string(),
uri: Url::from_file_path(&abs_path_of_demo).unwrap(),
name: "demo".to_string(),
}]),
..InitializeParams::default()
},
@ -694,11 +691,7 @@ mod tests {
workspaces_cache: Vec::new(),
};
let diagnostics = server
.get_diagnostics(
&adapter_conf,
abs_path_of_test_proj.to_str().unwrap(),
&files,
)
.get_diagnostics(&adapter_conf, abs_path_of_demo.to_str().unwrap(), &files)
.unwrap();
assert_eq!(diagnostics.len(), 1);
let diagnostic = diagnostics.first().unwrap().1.first().unwrap();