Skip to content

Commit

Permalink
fix windows ut
Browse files Browse the repository at this point in the history
Signed-off-by: He1pa <[email protected]>
  • Loading branch information
He1pa committed Nov 25, 2024
1 parent 3eab378 commit 46a03dd
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
6 changes: 2 additions & 4 deletions kclvm/parser/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1059,15 +1059,14 @@ pub fn load_all_files_under_paths(
}
}

let module_cache = module_cache.unwrap_or_default();
let module_cache = loader.module_cache.clone();
let pkgs_not_imported = &mut res.program.pkgs_not_imported;

let mut new_files = HashSet::new();

// Bfs unparsed and import files
loader.parsed_file.extend(unparsed_file.clone());
while let Some(file) = unparsed_file.pop_front() {
new_files.insert(file.clone());

let module_cache_read = module_cache.read();
match &module_cache_read {
Ok(m_cache) => match m_cache.ast_cache.get(file.get_path()) {
Expand Down Expand Up @@ -1216,7 +1215,6 @@ pub fn get_files_from_path(
let all_k_files_under_path = get_kcl_files(path, true)?;
for f in &all_k_files_under_path {
let p = PathBuf::from(f);

let fix_path = p
.parent()
.unwrap()
Expand Down
2 changes: 1 addition & 1 deletion kclvm/query/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ pub fn get_full_schema_type(
/// use maplit::hashmap;
/// use kclvm_ast::MAIN_PKG;
///
/// let work_dir_parent = Path::new(".").join("src").join("test_data").join("get_schema_ty_under_path");
/// let work_dir_parent = Path::new(env!("CARGO_MANIFEST_DIR")).join("src").join("test_data").join("get_schema_ty_under_path");
///
/// let result = get_full_schema_type_under_path(
/// None,
Expand Down
22 changes: 18 additions & 4 deletions kclvm/tools/src/LSP/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1427,19 +1427,19 @@ fn formatting_unsaved_test() {

#[test]
fn complete_import_external_file_e2e_test() {
let path = PathBuf::from(".")
let root = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.join("src")
.join("test_data")
.join("completion_test")
.join("import")
.join("external")
.join("external_1")
.join("external_1");
let path = root
.join("main.k")
.canonicalize()
.unwrap()
.display()
.to_string();

let _ = Command::new("kcl")
.arg("mod")
.arg("metadata")
Expand All @@ -1459,8 +1459,21 @@ fn complete_import_external_file_e2e_test() {
)
.output()
.unwrap();

let src = std::fs::read_to_string(path.clone()).unwrap();
let server = Project {}.server(InitializeParams::default());

let initialize_params = InitializeParams {
workspace_folders: Some(vec![WorkspaceFolder {
uri: Url::from_file_path(root.clone()).unwrap(),
name: "test".to_string(),
}]),
..Default::default()
};
let server = Project {}.server(initialize_params);

// FIXME: It takes longer to parse the k8s package on Windows
#[cfg(target_os = "windows")]
wait_async!(20000);

// Mock open file
server.notification::<lsp_types::notification::DidOpenTextDocument>(
Expand All @@ -1473,6 +1486,7 @@ fn complete_import_external_file_e2e_test() {
},
},
);
wait_async!(2000);

let id = server.next_request_id.get();
server.next_request_id.set(id.wrapping_add(1));
Expand Down

0 comments on commit 46a03dd

Please sign in to comment.