Skip to content
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

Timeout support #10

Closed
epage opened this issue May 29, 2018 · 4 comments · Fixed by #92
Closed

Timeout support #10

epage opened this issue May 29, 2018 · 4 comments · Fixed by #92
Labels
enhancement Improve the expected

Comments

@epage
Copy link
Contributor

epage commented May 29, 2018

In getting feedback, there came up the need for timeout support.

We'd have to run the command in a thread, sleep for the time (in small increments?), and then call kill if needed.

https://doc.rust-lang.org/std/process/struct.Child.html#method.kill

@epage epage added the enhancement Improve the expected label May 29, 2018
@epage
Copy link
Contributor Author

epage commented May 29, 2018

See discussion at assert-rs/assert_cli#67

@epage
Copy link
Contributor Author

epage commented Jun 20, 2018

From previous thread

Looks like this will be pretty trivial
https://crates.io/crates/wait-timeout

Nevermind, it doesn't support getting the output and it doesn't look like it will in the foreseeable future
alexcrichton/wait-timeout#4

epage pushed a commit to epage/assert_cmd that referenced this issue Dec 5, 2019
Many of our problems with `stdin` are derived from using extension
traits. By moving away from them, we fix the API problems and make it
easier to add other features like timeout (assert-rs#10) or signalling (assert-rs#84).

So the new philosphy if:
- Core functionality is provided by extension traits
- Provide a convinience API that makes `Command` friendlier. These do
  not need to be generalized.  Other abstractions can provide their own
  (like `duct`).

Fixes assert-rs#73
@vincentdephily
Copy link

For my use, I'm simply looping through all my currently-live commands and calling thread::sleep(10ms) before looping again. Not pretty but it works. I've found 10ms to be useful even on my slow-ish CI.

A better solution would use futures, but I'm not sure what futures are available to wait for process exit. Presumably, implementing those futures is assrt_cmd's job.

Note that I use a generic CmdCond enum which can describe a timeout condition but also "when that other command has exited" or "when that file matches a predicate".

You can steal code from https://gist.github.com/vincentdephily/592546c41ff9713adff234e5535aa6d4

@dylni
Copy link

dylni commented Mar 4, 2020

@epage I created a crate that should help with this:
https://crates.io/crates/process_control

You can use Child::with_output_timeout to get output from a process with a timeout.

epage pushed a commit to epage/assert_cmd that referenced this issue Mar 26, 2020
epage pushed a commit to epage/assert_cmd that referenced this issue Mar 26, 2020
We test with `failure` because Linux considers it `interrupted` but not
windows.  `failure` is common to both platforms.

Fixes assert-rs#10
@epage epage closed this as completed in #92 Mar 26, 2020
epage added a commit that referenced this issue Dec 4, 2023
chore(config): migrate renovate config
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improve the expected
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants