Comments (5)
Thanks, it looks like the ctrl-c needs to be forwarded from nextest to child test processes, similar to how signals are forwarded on Unix. The code for that just hasn't been written yet. Would you like to contribute a patch?
from nextest.
Thanks, it looks like the ctrl-c needs to be forwarded from nextest to child test processes, similar to how signals are forwarded on Unix. The code for that just hasn't been written yet. Would you like to contribute a patch?
How to contribute a patch to this? I don't have much knowledge on windows system programming.
What Windows APIs do I need to solve this? Thank you.
from nextest.
So looking at your test further, I'm now less sure of what's going on. It looks like the test sends ctrl-c to itself (which is fine) but for some reason nextest doesn't pick up on the test exiting until 60 seconds pass. I'm not actually sure what's going on. This is going to require some debugging.
I don't have time to do this for at least the next few weeks, so any assistance would be appreciated. It's worth just digging into whether
nextest/nextest-runner/src/runner.rs
Lines 744 to 746 in e815305
from nextest.
I encountered the same problem. After investigation, I found that this has nothing to do with nextest.
Create a sample project:
src/main.rs
:
use std::time::Duration;
use windows_sys::Win32::{
Foundation::GetLastError,
System::Console::{GenerateConsoleCtrlEvent, CTRL_C_EVENT},
};
fn send_ctrlc_later(duration: Duration) {
std::thread::spawn(move || {
std::thread::sleep(duration);
// send CTRL_C event to myself on windows platform
let pid = std::process::id();
println!("send CTRL_C event to myself({}) on windows platform", pid);
unsafe {
GenerateConsoleCtrlEvent(CTRL_C_EVENT, pid);
println!("GetLastError: {}", GetLastError());
}
});
}
fn main() {
let (sender, receiver) = std::sync::mpsc::channel();
ctrlc::set_handler(move || sender.send(()).unwrap()).expect("Error setting Ctrl-C handler");
send_ctrlc_later(Duration::from_secs(2));
let pid = std::process::id();
println!("Waiting for Ctrl-C: {}", pid);
receiver.recv().unwrap();
}
Cargo.toml
:
[dependencies]
ctrlc = "3.4.2"
no-panic = "0.1"
windows-sys = { version = "0.52", features = ["Win32_Foundation"] }
Run cargo test
, you will see:
Waiting for Ctrl-C: 12672
send CTRL_C event to myself(12672) on windows platform
GetLastError: 0
Run cargo test > emm.txt
, cargo will hang forever. You will see this in emm.txt
:
Waiting for Ctrl-C: 30380
send CTRL_C event to myself(30380) on windows platform
GetLastError: 6
GetLastError
returns 6, which means GenerateConsoleCtrlEvent
returns ERROR_INVALID_HANDLE
error. However, sending a key storke (e.g. space) in console unblocks the hang.
This is very obscure and I didn't find anything useful by googling :-(
Though GenerateConsoleCtrlEvent
returns error, ctrl c signal seems to be pushed into some kind of buffer. After stdio is activated(by typing in my case, by generating slow test message in nextest case), the ctrl c signal takes effect.
from nextest.
Huh, that's really strange. So it's specifically the fact that nextest redirects standard output that causes it? I don't quite understand, to be honest! It may be worth spending some time in Process Explorer to see what's going on.
I found this thread on StackOverflow which might be related, though I'm not sure.
I am wondering if nextest can do anything here. A few things that come to mind that might, but are not guaranteed, to help:
- create a process group on Windows
- poke at the console in some way, maybe? I'm way out of my Windows depth here.
from nextest.
Related Issues (20)
- Ability to specify a custom cargo profile? HOT 2
- `build.rs` line change slows tests HOT 2
- Ability to enable features in the configuration HOT 2
- Allow user-specific configuration
- Allow to display stdout, while silencing test harness. HOT 2
- Add support for excluding paths from an archive
- Archive extra files, relative to paths other than the target directory
- Add a way to include extra files on a per-test-binary and per-platform basis
- Add a "testimonials" page (please comment here!) HOT 3
- [windows] lots of tests running in parallel may cause "leaky" warnings HOT 3
- v0.9.70 using significantly more stack HOT 7
- Idea: network isolation between tests HOT 14
- Add support for `cargo test`s --skip and --exact command line flags HOT 1
- `cargo nextest run --workspace` fails with DLL missing if a macro lib exists HOT 14
- nextest chooses arbitrarily not to run some tests it's found HOT 6
- Consider conditions to not include libstd in archives
- [meta] tell users what configuration their tests are running with
- Human-readable configuration output HOT 1
- Machine-readable configuration output
- Feature Request: Conditional skipping test based on setup scripts
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nextest.