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.
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
Add WithExitCondition feature #242
Add WithExitCondition feature #242
Changes from 6 commits
f0e7778
6892a7e
31529e1
3aca5e3
a1dbfd8
2505aa5
1c8f829
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
Check failure on line 15 in CliWrap.Tests/ExitConditionSpecs.cs
GitHub Actions / main / test (ubuntu-latest)
I can execute a command that creates child process resuing standard output and finish after child process exits
Check failure on line 15 in CliWrap.Tests/ExitConditionSpecs.cs
GitHub Actions / main / test (macos-latest)
I can execute a command that creates child process resuing standard output and finish after child process exits
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.
executionStart
/executionFinish
is already provided byresult
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.
Yes, but finish time is a different one. CliWrap sets
ExitTime
when the main process ends. When there are child processes attached to output,ExecuteAsync()
is blocked until all children are completed. In this test, we want to measure time when theExecuteAsync()
was blocked for, so that we can verify whether it was waiting for child or not.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.
Exit time is set when the child process exits:
CliWrap/CliWrap/Utils/ProcessEx.cs
Lines 47 to 51 in 1cfa50e
It shouldn't be affected by the exit condition you've added, since that only affects whether CliWrap waits for pipes to clear or not.
Because your
var executionFinish = ...
statement appears rightawait cmd.ExecuteAsync()
, it's essentially the same (slightly later) timestamp as the one provided byExecutionResult
.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.
CliWrap's ExitTime is always the same no matter what
ExitCondition
is set. So this test would basically always pass.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.
I'm confused in that case. Wouldn't
ExitCondition.ProcessExit
make the command finish earlier, assuming it spawns a grandchild process?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.
Probably a more reliable way to test this would be to read the stdout. The
sleep
command printsDone.
after it finishes, so you can use that to detect whether the grandchild process has finished or not.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.
Unfortunately it's not possible. The main process is finished almost instantly, and there is nothing we can do to catch the output after that. We can handle the output and wait for for child process to be finished, but then it breaks the whole point of doing this test, where we are interested in specific scenario when parent triggers child and then dies instantly.
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.
I meant to test the current behavior (
PipesClosed
), wouldn'tDone
appear in the output since the command would only complete after the grandchild process exits?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.
Only if we make main process to wait for the child. In the
CliWrap.Tests.Dummy
I implementedrun process
command that doesn't wait for the child, because this is the behavior that can't be handled currrently.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.
In general it seems difficult to create a single test that works reliably on all environments including .NET framework and Linux. In Linux, we should somehow use
nohup
and background processing with bash to reproduce the issue, because the dummy app can't reproduce it.On .NET Framework those tests also fail, but I don't know why yet.
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.
I thought the issue is that, regardless of whether the child process waits for the grandchild or not, because the output streams are inherited and CliWrap waits for them to close, the command effectively finishes when all grandchildren exit.
Check failure on line 33 in CliWrap.Tests/ExitConditionSpecs.cs
GitHub Actions / main / test (windows-latest)
I can execute a command that creates child process resuing standard output and finish instantly after main process exits