Skip to content

Commit

Permalink
fix ut
Browse files Browse the repository at this point in the history
Signed-off-by: he1pa <18012015693@163.com>
  • Loading branch information
He1pa committed Nov 7, 2024
1 parent e2f0ab3 commit f70f256
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ubuntu_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ jobs:
go install kcl-lang.io/cli/cmd/kcl@main
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
echo "${{ github.workspace }}/go/bin" >> $GITHUB_PATH
- name: Unit test
working-directory: ./kclvm
run: export PATH=$PATH:$PWD/../_build/dist/linux/kclvm/bin && make test
shell: bash

19 changes: 8 additions & 11 deletions kclvm/tools/src/LSP/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,17 +192,13 @@ impl LanguageServerState {
for event in self.fs_event_watcher._receiver.try_iter() {
if let Ok(e) = event {
match e.kind {
notify::EventKind::Modify(modify_kind) => {
if let notify::event::ModifyKind::Data(data_change) = modify_kind {
if let notify::event::DataChange::Content = data_change {
let paths = e.paths;
let kcl_config_file: Vec<PathBuf> = filter_kcl_config_file(&paths);
if !kcl_config_file.is_empty() {
return Some(Event::FileWatcher(
FileWatcherEvent::ChangedConfigFile(kcl_config_file),
));
}
}
notify::EventKind::Modify(_) => {
let paths = e.paths;
let kcl_config_file: Vec<PathBuf> = filter_kcl_config_file(&paths);
if !kcl_config_file.is_empty() {
return Some(Event::FileWatcher(FileWatcherEvent::ChangedConfigFile(
kcl_config_file,
)));
}
}
notify::EventKind::Remove(remove_kind) => {
Expand Down Expand Up @@ -644,6 +640,7 @@ impl LanguageServerState {
&mut files,
opts.1.clone(),
);

log_message(
format!(
"Compile workspace: {:?}, main_pkg files: {:?}, changed file: {:?}, options: {:?}, metadate: {:?}, use {:?} micros",
Expand Down
1 change: 1 addition & 0 deletions kclvm/tools/src/LSP/src/test_data/watcher/modify/main.k
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import helloworld
16 changes: 1 addition & 15 deletions kclvm/tools/src/LSP/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1548,21 +1548,7 @@ fn mod_file_watcher_test() {
.unwrap();

// wait for download dependence
wait_async!(500);

server.notification::<lsp_types::notification::DidChangeTextDocument>(
lsp_types::DidChangeTextDocumentParams {
text_document: lsp_types::VersionedTextDocumentIdentifier {
uri: Url::from_file_path(main_path.clone()).unwrap(),
version: 1,
},
content_changes: vec![TextDocumentContentChangeEvent {
range: None,
range_length: None,
text: "import helloworld".to_string(),
}],
},
);
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 f70f256

Please sign in to comment.