-
Notifications
You must be signed in to change notification settings - Fork 12
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
Standard output truncated when using ssh with clitest #42
Comments
Is this related to issue #27?Through no fault of clitest, when writing to Althrough the fault here is the same (standard output getting trunctated), I don't think this issue is related to #27, see my investigation below. (It still could be of course, but this is my "hunch" after investigating a bit.) Does
|
This is a weird behaviour that happens without
Maybe it's related? 🤔 |
I found a workaround. When making an ssh call, just make sure we redirect its stdin:
Now it suddenly works:
This also applies to scripts that call ssh. If we make sure every call to ssh has its stdin being taken from a file, clitest works. Weird... 🤔 💭 |
@aureliojargas Btw, thanks for making and maintaining this awesome tool. I have been using clitest for some years now, it is very handy. |
I agree that this is a bug in A different test file that causes a similar bug (without using ssh) is the following:
Running it will return:
The problem is that when So the solution is probably to change the execution line for it to read from /dev/null when running a command, like: tt_run_test() {
...
eval "$tt_test_command" > "$tt_test_output_file" 2>&1 < /dev/null
...
} I tested the above change in the current master branch (a58e8aa) and it successfully ran the 272 tests of test.md. NOTE: ssh does at least 1 read from stdin on every execution. When running it inside a shell script or inside a loop it'll always eat at least one line from the running shell (what @rudymatela pointed in the examples above), so in such cases it's better to pass -n to it ( or |
Thank you both @rudymatela and @vmmello for the extensive investigation and solution! I'm really impressed and thankful for that. @vmmello could you open a pull request for the fix, to get it properly credited to you in the git history? |
Isolate STDIN among tests and among a test and clitest itself. This fixes the bug reported on issue aureliojargas#42 in which tests and clitest share STDIN, causing unexpected results when the command specified on a test reads from STDIN.
Isolate STDIN among tests and among a test and clitest itself. This fixes the bug reported on issue #42 in which tests and clitest share STDIN, causing unexpected results when the command specified on a test reads from STDIN.
Thank you both again, @vmmello's PR got merged and this issue should be fixed now. ❤️ |
Great @aureliojargas! Thanks for the fast evaluation and merge! |
The standard output gets truncated when using ssh with clitest.
Consider a host with an user
user
with passwordless authentication set up (ssh-keygen
andssh-copy-id user@localhost
).Consider also the following clitest file (
ssh.clitest
):The above tests should pass, but they do not, see:
The output of the third command gets truncated.
I am on an Arch Linux with:
What about running
ssh
inside a script?What about the following script?
When it is tested with the following clitest file (
ssh2.clitest
):The first test works, but the second does not:
Unfortunately, this means that
clitest
will not work for any script that usesssh
at some point.The text was updated successfully, but these errors were encountered: