Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: set the kpm related test cases to execute sequentially #973

Merged
merged 1 commit into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion kclvm/driver/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ fn test_parse_key_value_pair_fail() {
assert!(parse_key_value_pair(case).is_err());
}
}
#[test]

fn test_fill_pkg_maps_for_k_file_with_line() {
let root_path = PathBuf::from(".")
.join("src")
Expand Down Expand Up @@ -296,12 +296,15 @@ fn test_lookup_the_nearest_file_dir() {
path.canonicalize().unwrap().display().to_string()
);
}

#[test]
fn test_fetch_metadata_in_order() {
test_fetch_metadata();
println!("test_fetch_metadata() passed");
test_fill_pkg_maps_for_k_file();
println!("test_fill_pkg_maps_for_k_file() passed");
test_fill_pkg_maps_for_k_file_with_line();
println!("test_fill_pkg_maps_for_k_file_with_line() passed");
}

fn test_fetch_metadata() {
Expand All @@ -322,6 +325,8 @@ fn test_fetch_metadata() {
let vendor_home = get_vendor_home();

let metadata = fetch_metadata(path.clone());
// Show more information when the test fails.
println!("{:?}", metadata);
assert_eq!(metadata.is_err(), false);
let pkgs = metadata.unwrap().packages.clone();
assert_eq!(pkgs.len(), 1);
Expand Down
31 changes: 0 additions & 31 deletions kclvm/tools/src/LSP/src/goto_def.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,37 +107,6 @@ mod tests {
use proc_macro_crate::bench_test;
use std::path::PathBuf;

#[test]
#[bench_test]
fn goto_import_pkg_with_line_test() {
let path = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
let (file, program, _, _, gs) =
compile_test_file("src/test_data/goto_def_with_line_test/main_pkg/main.k");
let pos = KCLPos {
filename: file,
line: 1,
column: Some(15),
};

let res = goto_definition_with_gs(&program, &pos, &gs);

match res.unwrap() {
lsp_types::GotoDefinitionResponse::Scalar(loc) => {
let got_path = file_path_from_url(&loc.uri).unwrap();
let expected_path = path
.join("src/test_data/goto_def_with_line_test/dep-with-line/main.k")
.canonicalize()
.unwrap()
.display()
.to_string();
assert_eq!(got_path, expected_path)
}
_ => {
unreachable!("test error")
}
}
}

#[test]
#[bench_test]
fn goto_import_pkg_test() {
Expand Down
36 changes: 36 additions & 0 deletions kclvm/tools/src/LSP/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,42 @@ fn file_path_from_url_test() {
}

#[test]
fn test_lsp_with_kpm_in_order() {
goto_import_pkg_with_line_test();
println!("goto_import_pkg_with_line_test PASS");
complete_import_external_file_test();
println!("complete_import_external_file_test PASS");
}

fn goto_import_pkg_with_line_test() {
let path = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
let (file, program, _, _, gs) =
compile_test_file("src/test_data/goto_def_with_line_test/main_pkg/main.k");
let pos = KCLPos {
filename: file,
line: 1,
column: Some(15),
};

let res = goto_definition_with_gs(&program, &pos, &gs);

match res.unwrap() {
lsp_types::GotoDefinitionResponse::Scalar(loc) => {
let got_path = file_path_from_url(&loc.uri).unwrap();
let expected_path = path
.join("src/test_data/goto_def_with_line_test/dep-with-line/main.k")
.canonicalize()
.unwrap()
.display()
.to_string();
assert_eq!(got_path, expected_path)
}
_ => {
unreachable!("test error")
}
}
}

fn complete_import_external_file_test() {
let path = PathBuf::from(".")
.join("src")
Expand Down
Loading