-
-
Notifications
You must be signed in to change notification settings - Fork 385
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
Wait for app to exit normally after log streaming #1541
Conversation
8d7bad2
to
b806807
Compare
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.
This change makes sense; however, I don't think it's covering all the problem (or, at least, there's some interesting interactions in the edge cases you've described and the behavior).
To my reckoning, this is the full set of possible outcomes:
- Streamed output (e.g., macOS app)
- App exits normally
- App reports success
- App reports an error
- App doesn't report an exit state
- App exits with error
- App reports success
- App reports an error
- App doesn't report an exit state
- App doesn't exit
- App reports success
- App reports an error
- App doesn't report an exit state
- App exits normally
- Non-streamed output (e.g., Linux app, or dev mode)
- App exits normally
- App reports success
- App reports an error
- App doesn't report an exit state
- App exits with error
- App reports success
- App reports an error
- App doesn't report an exit state
- App doesn't exit
- App reports success
- App reports an error
- App doesn't report an exit state
- App exits normally
1.iii.c and 2.iii.c are of no concern, because there's been no exit condition.
In the 1.* cases, we only have the "reported" exit code (i.e., from the regex). There's no way to differentiate between case 1.i.X, 1.ii.X and 1.iii.X (for matching X). Ideally, case 1.ii.c would report an error to the user; on macOS, we get "Application quit abnormally (Exit code X)!" reported by the operating system, but that's not (and can't be?) caught by Briefcase. So - we just use the regex return value in each of the 1.* cases.
However, in the 2.* cases, we have both a process exit code and a "reported" exit code. Cases 2.i.a and 2.ii.b are consistent, so there's no observable problem (although it might be helpful to know if the process and reported error code are inconsistent in case 2.ii.b). 2.i.c and 2.ii.c are the "normal Toga app" cases, and they work fine as well. 2.iii.b also seems to work.
The problems I see are with:
- 2.i.b - the reported error and the successful exit code are inconsistent.
- 2.ii.a - the reported success and the failure exit code are inconsistent.
- 2.iii.a - as of this PR, this case is reported as a failure.
I'd suggest that if either source reports a failure, a failure should be surfaced - so both 2.i.b and 2.ii.a should be failures, but reported differently to the user (so they can differentiate between the two). Case 2.iii.a should be a success; it's currently failing because the log stream has been killed (so the popen return code is nonzero).
I was initially quite confused by the labeling of 1 and 2; I think that "proxied app log streaming" and "direct app log streaming", respectively, may help better differentiate the two cases. This also doesn't really incorporate the added complexity of running with and without the As for what this PR does in relation to this analysis, IMO, it doesn't really do anything about 2.iii.a...because this PR was just ensuring the existing code would always be consistent with what it was trying to do. Right now, if you aren't using the All that said....you're suggesting we change the existing behavior to evaluate both outcomes in an AND condition. I kinda think we should go the other direction... So, I think we should consider the use-cases. Why is someone running Given this, I feel like we should treat the run as successful if the reported outcome is successful....regardless of the returncode from the app process. This is already true if you're running in However, when not using A bit long-winded...but thoughts? |
FWIW, a while back, we implemented |
I'm suggesting that if we have both, they should be the same; if they're not, we should report that fact (and that case is itself an error... but then, one of the two exit values has already indicated that there's an error of some kind). If we only have one, we should report it, but in a way that I can tell that there's a difference between "the app exited on it's own" and "My log sentinel stopped the app". The general expectation (whether test run or not) should be that the sentinel is immediately followed by an app exit with the same exit status. The only real exception to this is the case of mobile apps, which don't ever really "exit".
We already do use this to track if the app has exited on macOS. What we can't do is extract the status code of the process when it exits. |
Well, what if we consider this discussion orthogonal (or parallel?) to this PR? Whether we change anything about differences in "reported outcome" vs "process outcome", the changes in this PR are necessary because regardless of how all this behaves, we have to allow the app some time to exit on its own before we command it to exit....and that's all this PR is doing. I'm also saying this because I already have so many dependent PRs in flight and I wasn't trying to refactor all this right now. |
That's fair. I raised this in my review because I was seeing some inconsistent behavior in how sentinel values were handled in the non-test case - but they're no less consistent as a result of this patch, it's just more obvious because I was looking at it.
:-) |
Changes
Popen
process after log streaming and usespoll()
to determine the returncodeNotes
--test
because Briefcase doesn't care what happens to the app after the exit condition is found in its output.Popen
process to determine success.PR Checklist: