Skip to content

Commit

Permalink
move some test data file
Browse files Browse the repository at this point in the history
Signed-off-by: he1pa <[email protected]>
  • Loading branch information
He1pa committed Nov 20, 2024
1 parent 92e86aa commit 5e0736c
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion kclvm/tools/src/LSP/src/document_symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ mod tests {
#[test]
#[bench_test]
fn document_symbol_test() {
let (file, _, _, gs) = compile_test_file("src/test_data/document_symbol.k");
let (file, _, _, gs) = compile_test_file("src/test_data/document_symbol/document_symbol.k");

let mut res = document_symbol(file.as_str(), &gs).unwrap();
let mut expect = vec![];
Expand Down
7 changes: 6 additions & 1 deletion kclvm/tools/src/LSP/src/quick_fix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,12 @@ mod tests {
fn quick_fix_test() {
let path = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
let test_file = path.clone();
let test_file = test_file.join("src").join("test_data").join("quick_fix.k");
let test_file = test_file
.join("src")
.join("test_data")
.join("code_action")
.join("quick_fix")
.join("quick_fix.k");
let file = test_file.to_str().unwrap();

let diags = compile_with_params(Params {
Expand Down
2 changes: 2 additions & 0 deletions kclvm/tools/src/LSP/src/test_data/diagnostics/load_pkg_test.k
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
schema Person:
age: int
13 changes: 7 additions & 6 deletions kclvm/tools/src/LSP/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ fn build_lsp_diag(
fn build_expect_diags() -> Vec<Diagnostic> {
let path = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
let mut test_file = path.clone();
test_file.push("src/test_data/diagnostics.k");
test_file.push("src/test_data/diagnostics/diagnostics.k");
let file = test_file.to_str().unwrap();
let expected_diags: Vec<Diagnostic> = vec![
build_lsp_diag(
Expand All @@ -267,7 +267,7 @@ fn build_expect_diags() -> Vec<Diagnostic> {
build_lsp_diag(
(0, 0, 0, 10),
format!(
"Cannot find the module abc from {}/src/test_data/abc",
"Cannot find the module abc from {}/src/test_data/diagnostics/abc",
path.to_str().unwrap()
),
Some(DiagnosticSeverity::ERROR),
Expand Down Expand Up @@ -332,7 +332,7 @@ fn build_expect_diags() -> Vec<Diagnostic> {
fn diagnostics_test() {
let path = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
let mut test_file = path.clone();
test_file.push("src/test_data/diagnostics.k");
test_file.push("src/test_data/diagnostics/diagnostics.k");
let file = test_file.to_str().unwrap();

let diags = compile_with_params(Params {
Expand All @@ -350,6 +350,7 @@ fn diagnostics_test() {
.collect::<Vec<Diagnostic>>();

let expected_diags: Vec<Diagnostic> = build_expect_diags();

for (get, expected) in diagnostics.iter().zip(expected_diags.iter()) {
assert_eq!(get, expected)
}
Expand Down Expand Up @@ -764,7 +765,7 @@ fn notification_test() {
let root = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
let mut path = root.clone();

path.push("src/test_data/diagnostics.k");
path.push("src/test_data/diagnostics/diagnostics.k");

let path = path.to_str().unwrap();
let src = std::fs::read_to_string(path).unwrap();
Expand All @@ -783,7 +784,7 @@ fn notification_test() {
);

// Wait for first "textDocument/publishDiagnostics" notification
server.wait_for_message_cond(2, &|msg: &Message| match msg {
server.wait_for_message_cond(1, &|msg: &Message| match msg {
Message::Notification(not) => not.method == "textDocument/publishDiagnostics",
_ => false,
});
Expand Down Expand Up @@ -817,7 +818,7 @@ fn close_file_test() {
let root = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
let mut path = root.clone();

path.push("src/test_data/diagnostics.k");
path.push("src/test_data/diagnostics/diagnostics.k");

let path = path.to_str().unwrap();
let src = std::fs::read_to_string(path).unwrap();
Expand Down

0 comments on commit 5e0736c

Please sign in to comment.