From f70f256689bfbccdf5b71b133961fc3bb2bc8c21 Mon Sep 17 00:00:00 2001 From: he1pa <18012015693@163.com> Date: Thu, 7 Nov 2024 12:01:12 +0800 Subject: [PATCH] fix ut Signed-off-by: he1pa <18012015693@163.com> --- .github/workflows/ubuntu_test.yaml | 2 +- kclvm/tools/src/LSP/src/state.rs | 19 ++++++++----------- .../LSP/src/test_data/watcher/modify/main.k | 1 + kclvm/tools/src/LSP/src/tests.rs | 16 +--------------- 4 files changed, 11 insertions(+), 27 deletions(-) diff --git a/.github/workflows/ubuntu_test.yaml b/.github/workflows/ubuntu_test.yaml index 1ca29c7e0..de8fbc61d 100644 --- a/.github/workflows/ubuntu_test.yaml +++ b/.github/workflows/ubuntu_test.yaml @@ -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 + diff --git a/kclvm/tools/src/LSP/src/state.rs b/kclvm/tools/src/LSP/src/state.rs index c31e4b950..a74ba395b 100644 --- a/kclvm/tools/src/LSP/src/state.rs +++ b/kclvm/tools/src/LSP/src/state.rs @@ -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 = 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 = 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) => { @@ -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", diff --git a/kclvm/tools/src/LSP/src/test_data/watcher/modify/main.k b/kclvm/tools/src/LSP/src/test_data/watcher/modify/main.k index e69de29bb..f5bde4bd0 100644 --- a/kclvm/tools/src/LSP/src/test_data/watcher/modify/main.k +++ b/kclvm/tools/src/LSP/src/test_data/watcher/modify/main.k @@ -0,0 +1 @@ +import helloworld \ No newline at end of file diff --git a/kclvm/tools/src/LSP/src/tests.rs b/kclvm/tools/src/LSP/src/tests.rs index 6dac71010..6de2d1dd9 100644 --- a/kclvm/tools/src/LSP/src/tests.rs +++ b/kclvm/tools/src/LSP/src/tests.rs @@ -1548,21 +1548,7 @@ fn mod_file_watcher_test() { .unwrap(); // wait for download dependence - wait_async!(500); - - server.notification::( - 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));