-
Notifications
You must be signed in to change notification settings - Fork 141
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
Feature Request: Exec must return a struct that contains exit code, stdout, stderr #617
Comments
Hi @Warchant, We currently provide the ability to pass let cmd = ExecCommand::new(...).with_cmd_ready_condition(WaitFor::message_on_stdout("..")); But I understand the benefit of being able to get all the logs and execution code. |
Another good point is that we ideally need to provide the logs as a stream of bytes, since the logs may not be valid |
@DDtKey for my use-case it is not really necessary to access stdout & stderr separately. I see that bollard API does not allow to easily separate those. Maybe first version can just return a single stream? testcontainers-rs/testcontainers/src/core/client.rs Lines 99 to 100 in 7f60b02
attach_stdout: Some(true) and attach_stderr: Some(true) and then just return output: Pin<Box<dyn Stream<Item = Result<LogOutput, Error>> + Send>>, to the user.
|
Hm, if you don’t need to distinguish I guess the common use-case is to verify the content. Thus, as a first step, we could consider the following suggestion: have something like |
- support check of exit code - allow check the message against both `stderr` and `stdout` Closes #617
I've prepared the implementation of the suggestion @Warchant please, take a look, let me know what do you think |
- support check of exit code - allow check the message against both `stderr` and `stdout` - extend `new` to accept `impl IntoIterator<Item = impl Into<String>>` (e.g to accept `["cmd", "arg1", "arg2"]` as is) Closes #617
We may still consider your suggestion if you really need full access to the logs, but these approaches don't block each other. So don't hesitate to reopen if you feel that #622 doesn't cover this issue. |
@DDtKey when I exec something, is there a way to actually read stdout/stderr/both in my test? |
That was the question, if you need access to logs or checking the result is enough. I will extend API to return logs for such use-case, and they will be accessible independently (both stdout and stderr, but you can distinguish them). |
I'll do that during the week, will try to implement asap. |
Sorry for the delay, bandwidth was quite limited for longer period of time. I'll notify you once it's ready! |
Reopening since I'm working on this and it was an irrelevant status for the issue. Also, changes I've prepared will be useful for #502 as well Milestone is assigned and relevant |
Hi @Warchant and everybody interested in this feature! I've spent much more time to bring this into Thank you for patience! |
Closes #502 Exposes `stdout` and `stderr` methods, which returns: - `tokio::io::AsyncBufRead` impl for async container - `std::io::BufRead` impl for sync container (under `blocking` feature) Also, small alignment is performed (related to #617): - rename the `ExecResult` `stdout`/`stderr` methods to match the container methods
Current exec has this signature
pub async fn exec(&self, cmd: ExecCommand) {
. It returns nothing.In my tests I want to run a command and process resulting exit code & logs (both stderr & stdout).
Is it possible to add support for this feature?
The text was updated successfully, but these errors were encountered: