-
Notifications
You must be signed in to change notification settings - Fork 163
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
test_no_spawn_no_stdin_attached tests the build environment #1580
Comments
Thanks for reporting.
Is this a broken test or alot's functionality malforming?
Either way, a PR would be welcome.
Cheers,
P
|
I think it's only the test, it only affects some build environments and the application itself is probably fine. |
The test code is this: @utilities.async_test
async def test_no_spawn_no_stdin_attached(self):
ui = utilities.make_ui()
cmd = g_commands.ExternalCommand('test -t 0', refocus=False)
await cmd.apply(ui)
ui.notify.assert_not_called() The @kpcyrd I think "it seems the test heavily depends on the terminal attached to the build" is a little to strong, my conclusion would be "the test depends an any terminal being attached". And then my question is: Is there a terminal attached to the build? What kind of infrastructure are you using to run these tests? Do I assume correctly that And the question @pazz and @dcbaker is: This test was introduced in 5f96f0d , do we really need a terminal or can we test this some other way? What exactly are we trying to test? |
That set of tests is fixed in the next commit, which seems to be for #1137, so what's supposed to be tested is that the subprocess.Popen call is invoked with it's |
The same test was troubling me when running tests in github ci: 7bf4dee |
Sorry for not following up for 2 years, the infrastructure this is running on is https://reproducible.archlinux.org/, the chain of execution is This is done so the website can show the build output for all the packages we build. |
We have a nix flake in this repository and nix also sets stdin to /dev/null in the build sandbox. I just verified this and inside the build sandbox of nix I get
So if the test succeeds in the nix sandbox it should also succeed in the arch sandbox. |
@lucc about your question above, I 'd be surprised if any of our tests actually require a terminal. |
@pazz I conclude from @dcbaker's comment that we do not need to test for an actual terminal device to be attached. We rather want to know if we are successfully redirecting text into stdin or if we pass We could either find a shell command that gives the correct exit status in all environments where we want to run our tests (terminal, github, nix, arch build, etc). For this I played around in a terminal for a bit and came up with this. $ t () {
> test -t 0; echo "test -t 0 ==> $?"
> test -p /dev/stdin; echo "test -p /dev/stdin ==> $?"
> test -c /dev/stdin; echo "test -c /dev/stdin ==> $?"
> }
$ t
test -t 0 ==> 0
test -p /dev/stdin ==> 1
test -c /dev/stdin ==> 0
$ echo foo | t
test -t 0 ==> 1
test -p /dev/stdin ==> 0
test -c /dev/stdin ==> 1
$ cat /dev/null | t
test -t 0 ==> 1
test -p /dev/stdin ==> 0
test -c /dev/stdin ==> 1
$ t < /dev/null
test -t 0 ==> 1
test -p /dev/stdin ==> 1
test -c /dev/stdin ==> 0 Maybe Alternatively we can rewrite the test to check if Popen did some redirection of stdin. We can get the full path of stdin of our python test code with |
For me this change makes the tests succeed in the terminal and in the nix sandbox. I am running Linux so maybe that is different on Mac or BSD. Can somebody confirm? diff --git a/flake.nix b/flake.nix
index 339f6587..3cd0609a 100644
--- a/flake.nix
+++ b/flake.nix
@@ -36,10 +36,6 @@
nativeCheckInputs = with pkgs; [ gnupg notmuch procps ];
checkPhase = ''
- # In the nix sandbox stdin is not a terminal but /dev/null so we
- # change the shell command only in this specific test.
- sed -i '/test_no_spawn_no_stdin_attached/,/^$/s/test -t 0/sh -c "[ $(wc -l) -eq 0 ]"/' tests/commands/test_global.py
-
python3 -m unittest -v
'';
});
diff --git a/tests/commands/test_global.py b/tests/commands/test_global.py
index 775a822c..8932f77a 100644
--- a/tests/commands/test_global.py
+++ b/tests/commands/test_global.py
@@ -124,19 +124,19 @@ class TestExternalCommand(unittest.TestCase):
@utilities.async_test
async def test_no_spawn_no_stdin_attached(self):
ui = utilities.make_ui()
- cmd = g_commands.ExternalCommand('test -t 0', refocus=False)
+ cmd = g_commands.ExternalCommand('test -p /dev/stdin', refocus=False)
await cmd.apply(ui)
- ui.notify.assert_not_called()
+ ui.notify.assert_called_once_with(
+ 'editor has exited with error code 1 -- No stderr output',
+ priority='error')
@utilities.async_test
async def test_no_spawn_stdin_attached(self):
ui = utilities.make_ui()
cmd = g_commands.ExternalCommand(
- "test -t 0", stdin='0', refocus=False)
+ "test -p /dev/stdin", stdin='0', refocus=False)
await cmd.apply(ui)
- ui.notify.assert_called_once_with(
- 'editor has exited with error code 1 -- No stderr output',
- priority='error')
+ ui.notify.assert_not_called()
@utilities.async_test
async def test_no_spawn_failure(self): |
hello, just letting you know alot currently fails in the Arch Linux reproducible builds system.
Since the original build passed it seems the test heavily depends on the terminal attached to the build, which it shouldn't.
The text was updated successfully, but these errors were encountered: