-
Notifications
You must be signed in to change notification settings - Fork 0
WASM agent coverage #88
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| //! Long-lived in-process ws-server for the `wasm-agent-cov` coverage task. | ||
| //! | ||
| //! Starts the same hub the integration tests use on a fixed port (the one the browser wasm-agent tests connect | ||
| //! to), writes a readiness marker to the file named by the first CLI argument once the server is accepting, then | ||
| //! stays up until the task deletes that marker -- its stop signal. Returning from `main` (rather than being | ||
| //! killed) lets the coverage-instrumented build flush its counters on a clean exit; a SIGKILL would drop them. | ||
| //! | ||
| //! Excluded from Codacy analysis (`.codacy.yaml`): Codacy's Rust security rule flags `args_os()` flowing into a | ||
| //! file operation as a path-traversal shape and cannot suppress it per line. That is a false positive here -- the | ||
| //! single argument is the marker path the trusted `wasm-agent-cov` mise task passes -- and taking that path as an | ||
| //! argument (rather than hardcoding one) is the point. The crate exposes this as its own minimal file so the path | ||
| //! exclude stays narrow; it is still covered by clippy and `DeepSource`'s Rust analyzer. | ||
|
|
||
| use std::error::Error; | ||
| use std::path::PathBuf; | ||
| use std::time::Duration; | ||
|
|
||
| use fs_err as fs; | ||
|
|
||
| /// Fixed port the browser wasm-agent tests dial (`ws://127.0.0.1:8080/ws`), matching the ws-server port the | ||
| /// existing `web.rs` end-to-end test and `ws-e2e-chrome` use. | ||
| const COV_SERVER_PORT: u16 = 8080; | ||
|
|
||
| fn main() -> Result<(), Box<dyn Error>> { | ||
| let ready_path = std::env::args_os() | ||
| .nth(1) | ||
| .map(PathBuf::from) | ||
| .ok_or("usage: cov-server <ready-file>")?; | ||
|
|
||
| let server = et_ws_test_server::start_on(COV_SERVER_PORT); | ||
| fs::write(&ready_path, server.ws_url.as_bytes())?; | ||
|
|
||
| // Stay up until the task removes the readiness marker, then fall through to a clean exit so coverage flushes. | ||
| while ready_path.exists() { | ||
| std::thread::sleep(Duration::from_millis(100)); | ||
| } | ||
| Ok(()) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
Preserve the clean shutdown protocol on failure.
The EXIT trap directly kills the instrumented server, so failures before Line 224 prevent
main()from returning andcan discard its native profile. Have the trap remove the readiness marker and reap the process, with
killonly as abounded fallback.
🤖 Prompt for AI Agents