-
-
Notifications
You must be signed in to change notification settings - Fork 2
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
Run windows tests in multiple shells #20
Conversation
…rr on the annoying operating system Issue-duty#23: pawamoy/duty#23
…nd stderr on the annoying operating system
Great, so it passes with powershell. Could you now remove the fix (setting the env var) to see if it actually fails? |
Hmmm actually it looks like the |
OK it's not implicit, because as you can see both the bash and pwsh jobs use |
Thank you for all this 🚀 |
Ha, so many comments. Yes, I am an inexpert GitHub action person. I intended to flail about privately before embarrassing myself, but now I'm in the public eye. Expect way too many updates here. You might want to mute the thread! |
I actually slightly fear that running |
a59def2
to
f2f074e
Compare
Valid concern 🤔 Well, we'll know for sure if you manage to get one test job to fail on PowerShell. If you can't make it fail, you might want to customize the step indeed, to run Python directly, without |
ccfd3e3
to
d4a1c5a
Compare
d4a1c5a
to
2446bdd
Compare
88b73df
to
9339e1d
Compare
Flushing issue. You can try to add Or you could move the |
…put is in expected order
a361e4d
to
8836214
Compare
Too bad, tests passing even without the fix. |
Hey. Work was busy. Sorry you had to turn off the fix. I'm flummoxed by the results I see. With the fix, I still have a poor user experience. My hand-rolled "smoketest" fails. With this code: import failprint
import sys
import time
def passing():
time.sleep(1)
print("I'm passing")
return 0
def failing():
time.sleep(1)
print("I'm failing")
return 1
failprint.run(vars()[sys.argv[1]], capture=sys.argv[2])
If I set PYTHONLEGACYWINDOWSSTDIO="1" first, then all combinations above exit with code 1 and prints error indicating that "UnicodeEncodeError: 'charmap' codec can't encode character '\u2717' in position 5: character maps to " (or If I then also set PYTHONIOENCODING="UTF-8" (as the github actions have) and repeat, the smoketests behave as you'd hope ("I'm failing" always printed, "I'm passing" only with capture=none), but the fancy glyphs are mangled, with what's probably their 3 UTF-8 bytes rendered directly as CP1252 characters (I'm too lazy to look, but "Γ£ô" and "Γ£ù". Feels right.) I think running in pytest or possibly on github machines is confounding the results. I'm going to amend the job to also run the smoketests. Update Now that I'm saying it out loud, it seems reasonable that stdout and stderr aren't what we've come to expect on Windows even when running in pwsh on a Windows GitHub Action runner. They're capturing the output somehow. Even preprending timestamps if you look close enough. |
Oh OK, I thought the result was "worse" than that. I'd consider it solved on failprint's side with |
I did not expect a reply at 03:00! But anyhow, we currently seem to be at a point where user-side, we can workaround by setting PYTHONLEGACYWINDOWSSTDIO and maybe PYTHONIOENCODING (or just the former and using a different template). But so far failprint changes don't seem to be doing much good for your average Windows user... |
🤫 I'll probably add the env var to failprint anyway and add a small paragraph in the docs of both failprint and duty to recommend setting the UTF8 env vars for Windows users. |
Sorry, I am a little lost. The environment variable, when set from within failprint, does nothing, as far as I can tell. I guess it would affect further pythons spawned from within failprint. But is there a real advantage to setting it within failprint? (I also wonder if the naive trick of swapping out I am on the side investigating the cp1252 issue, but work interferes. Also, there's no stacktrace. You go from print to the complaint about the encoding! |
My understanding was that this would solve the "invalid handle" error, but since I can't try for myself, I can't say for sure. It does fix it for you, though you probably set the env var higher in the stack. I thought setting it right before doing the What our tests here have shown is not that setting the env var in failprint does nothing, but that we can't reproduce the "invalid handle" issue in GitHub Actions. If you can confirm this "invalid handle" issue is indeed fixed by failprint setting the env var (and you not setting it yourself), I'll push and release this change. If it doesn't fix the "invalid handle" issue for you, there's indeed no point in making the change, and I'll only document the env var in a troubleshooting section. Let me know if anything is unclear! |
Hey, if I take the current branch and revert 418defa, so failprint sets Setting To sum up: I don't think merging your change to the |
More on the environment variable. I've never read the python source before, but for CPython it seems to me that PYTHONLEGACYWINDOWSSTDIO is read to establish initial configuration, right at startup, and then a config object is passed around to affect later behaviour: which would support the finding that setting the environment variable after startup made no difference |
I see, thank you for confirming! Then yeah, no need to change anything in failprint, and I'll just document this in a troubleshooting section 🙂 |
Thanks. And I'm sorry it hasn't worked out better. I had high hopes, but it seems you're doing things that Windows just doesn't want you to. Me, for now I'm probably going to try using duty with subprocess-based duties instead of callable. It's not satisfying, but will probably work well enough that I'll not notice any problems. Out of curiosity, are you interested in either
I realize Windows isn't your target platform so if you'd rather not even see PRs, I will drop the idea right now. Otherwise, I'm happy to submit them for you to reject! Again, sorry nothing more useful has come from the bug reports/PRs. Regardless, I've had a good time trying. You've been very accommodating. |
|
And no worries, I enjoyed our interactions too and learned a few things, so all good! |
Closing. As discovered, the GitHub Actions prevent us from testing with proper Windows streams, so the behaviour that prompted this PR cannot be reproduced. See pawamoy/duty#23 (comment) for a summary of the findings. |
From pawamoy/duty#23, which identified problems running failprint on Windows, specifically when not run under a bash-like shell.
The current CI builds run the Windows tests using git bash and so don't surface the problem.