Skip to content

WIP - feat(lsp): Run tests with file watcher#27762

Closed
stefnotch wants to merge 10 commits intodenoland:mainfrom
stefnotch:feat/test-continuous-run
Closed

WIP - feat(lsp): Run tests with file watcher#27762
stefnotch wants to merge 10 commits intodenoland:mainfrom
stefnotch:feat/test-continuous-run

Conversation

@stefnotch
Copy link
Contributor

This addresses issue denoland/vscode_deno#1132

See linked PR for more context denoland/vscode_deno#1243

This pull request is not ready for merging yet. I opened it so that I can ask questions about my code, and about how to best achieve certain results.

I did my best to implement the following

  • Hooking up the existing error line reporting
  • Hooking up the existing expected vs actual reporting
  • Supporting "watch mode" for tests that are started from the LSP.

I did not yet

  • Use the changed_files of the file watcher
  • Clean out the debug logging
  • Rebase all the commits with good messages

My questions are left as comments in the code.

Also, this is more of a personal struggle: I initially really struggled to locally build Deno, as Deno requires some dependencies that are nontrivial to install on Windows.
The instructions were incomplete #27535 Upon updating them, nathanwhit figured out how to change libuv-sys-lite to no longer require the LLVM dependency, which was very nice.
The CMake dependency for libz-sys is still there, and it still causes me troubles, so I tweaked it (zlib-ng-no-cmake-experimental-community-maintained). My hope is that zlib will eventually get replaced by zlib-rs, which just works.

@CLAassistant
Copy link

CLAassistant commented Jan 21, 2025

CLA assistant check
All committers have signed the CLA.

file_watcher::PrintConfig::new("Test", false),
file_watcher::WatcherRestartMode::Automatic,
self.token.clone(),
move |flags, watcher_communicator, changed_paths| {
Copy link
Contributor Author

@stefnotch stefnotch Jan 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not entirely sure which files I should pass to the watcher_communicator, and what to do with the changed_paths. I did look at the other places where the file watcher is used, but there the file patterns are part of the CLI arguments.

Meanwhile here, the list of included files are set through the included and excluded tests. Any pointers would be very appreciated.

let line_number = user_frame.line_number.map(|v| v - 1)? as u32;
let column_number =
user_frame.column_number.map(|v| v - 1).unwrap_or(0) as u32;
Some(TestLocation {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This info lets us show an indicator at the assertEquals() that actually failed.

I couldn't really find a better way of figuring out where in the user code the error happened. Is this really it?

deno_unsync = { workspace = true, features = ["tokio"] }
faster-hex.workspace = true
flate2 = { workspace = true, features = ["zlib-ng-compat"] }
flate2 = { workspace = true, features = ["default"] }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is one of the changes that I'll get rid of when rebasing and fixing the PR. Currently that's just to not require the CMake dependency when developing locally.


[dev-dependencies]
libuv-sys-lite = "=1.48.2"
libuv-sys-lite = { version = "=1.48.3", features = ["dyn-symbols"] }
Copy link
Contributor Author

@stefnotch stefnotch Jan 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change will hopefully not be needed much longer. Hopefully Deno will update its libuv-sys-lite dependency soon :)

#27787

@stefnotch
Copy link
Contributor Author

Looks like Deno has been updated a bit since then. I'll happily update this PR to the latest version if that helps with reviewing it.

@bartlomieju
Copy link
Member

Hey @stefnotch, sorry for a slow response. Could you give me some context what this PR is trying to achieve? Seeing changes to so many Cargo.toml files is concerning, and so is TestFailure::Expected - but maybe I'm just missing some context.

@stefnotch
Copy link
Contributor Author

stefnotch commented May 7, 2025

Hi! Thank you for looking at this PR.

My goal is to add the equivalent of the --watch flag to the LSP's test runner.

The Cargo.toml changes are unrelated, they're just because I really struggled with getting Deno to build on my Windows system. I'll remove those, sorry for accidentally including them.

  • libuv-sys-lite has a cmake dependency. This should get fixed once the dependency is updated chore: re-enable napi uv test #27787
  • zlib also has a cmake dependency. There I tweaked it to use zlib-rs.

The TestFailure::Expected logic is so that we can properly report the expected and actual values to the LSP. Now that you mention it, I think I should pull that out of this PR. Will do so later :)

The biggest other struggle that I have is that re-implementing the entire watch logic means duplicating quite a bit of nontrivial code. See also #29132

@stefnotch
Copy link
Contributor Author

stefnotch commented May 8, 2025

Okay, I started pulling out an unrelated change to #29221

I also finally got Deno to compile on my Windows system. Only involved

  • Installing cmake via Visual Studio, as the docs recommend
  • Adding it to the path, since the Visual Studio installer does not do that
  • Installing clang/LLVM
  • Adding it to the path as well

Hopefully we'll someday have a world with fewer C++ dependencies. I miss the nice Cargo guarantee of "clone git repository, cargo build and it works".

@stefnotch
Copy link
Contributor Author

Since it is unlikely that I'll finish this particular PR before #29132 gets resolved, I'll close this. I opened an issue for bookkeeping. #29293

@stefnotch stefnotch closed this May 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants