Skip to content
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

1 test fails on WSL Debian #2996

Open
polluks opened this issue Dec 18, 2023 · 14 comments
Open

1 test fails on WSL Debian #2996

polluks opened this issue Dec 18, 2023 · 14 comments

Comments

@polluks
Copy link
Contributor

polluks commented Dec 18, 2023

Describe the bug
FAIL: tests/shtest

To Reproduce
make check

Expected behavior
FAIL: 0

Environment:

  • OS and Version: Linux Debian 10
  • jq version jq-1.6rc1-510-gfb8cc53

Additional context
test-suite.log

@itchyny
Copy link
Contributor

itchyny commented Dec 18, 2023

We run check on CI so it works for us. Looks like an issue of NO_COLOR support, but I have no clue. Please describe more information about how you build and run tests.

@itchyny itchyny added the test label Dec 18, 2023
@emanuele6
Copy link
Member

That test is assuming that the login shell of the current user is a POSIX shell; it probably has something to do with that

@emanuele6
Copy link
Member

Can you please try this patch?

diff --git a/tests/shtest b/tests/shtest
index 14aafbf..ca7e41f 100755
--- a/tests/shtest
+++ b/tests/shtest
@@ -507,11 +507,11 @@ test_no_color=true
 $msys  && test_no_color=false
 $mingw && test_no_color=false
 if $test_no_color && command -v script >/dev/null 2>&1; then
-  unset NO_COLOR
-  if script -qc echo /dev/null >/dev/null 2>&1; then
-    faketty() { script -qec "$*" /dev/null; }
-  else # macOS
-    faketty() { script -q /dev/null "$@" /dev/null |
+  unset -v NO_COLOR
+  if script -qc true /dev/null >/dev/null 2>&1; then
+    faketty() { SHELL=sh script -qec "$*" /dev/null; }
+  else # BSD
+    faketty() { SHELL=sh script -q /dev/null -- "$@" /dev/null |
       sed 's/^\x5E\x44\x08\x08//'; }
   fi
 

@emanuele6
Copy link
Member

emanuele6 commented Dec 18, 2023

Also, I am confused by that sed command on MacOS, because I am pretty sure s/^/\x12/ does not work in macOS sed.
Maybe s/^\x12// works though. Could someone check with printf '\x12HELLO\n' | sed -n 's/^\x12//; l' on macOS?
(If you see just HELLO$, it works; if you see somethingHELLO$ it does not work)

In any case, we should probably just use something more portable like bs=$(printf \\b); sed "1s/^^D$bs$bs//"

@wader
Copy link
Member

wader commented Dec 18, 2023

@emanuele6 macOS

$ printf '\x12HELLO\n' | sed -n 's/^\x12//; l'
HELLO$

@polluks
Copy link
Contributor Author

polluks commented Dec 19, 2023

@emanuele6 Sorry, your patch didn't help. I'm using a simple bash.

  _____      stefan@Stefan-PC
 /  __ \     os     Debian GNU/Linux 10 (buster) on Windows 10 [WSL2]
|  /    |    host   x86_64
|  \___-     kernel 4.4.0-19041-Microsoft
-_           uptime 30m
  --_        pkgs   1434
             memory 6192M / 16335M

test-suite.log

@itchyny
Copy link
Contributor

itchyny commented Dec 19, 2023

@polluks Can you try the following commands on the terminal?

/home/stefan/g/jq/jq --version
NO_COLOR=1 /home/stefan/g/jq/jq -n . | od -tc
NO_COLOR=1 script -qec /home/stefan/g/jq/jq -n . /dev/null | od -tc

@emanuele6
Copy link
Member

Or

/home/stefan/g/jq/jq --version
NO_COLOR=1 /home/stefan/g/jq/jq -n . | od -tc
NO_COLOR=1 script -qec '/home/stefan/g/jq/jq -n .' /dev/null | od -tc

@polluks
Copy link
Contributor Author

polluks commented Dec 20, 2023

$ /home/stefan/g/jq/jq --version
jq-1.6rc1-510-gfb8cc53-dirty
$ NO_COLOR=1 /home/stefan/g/jq/jq -n . | od -tc
0000000   n   u   l   l  \n
0000005
$ NO_COLOR=1 script -qec '/home/stefan/g/jq/jq -n .' /dev/null | od -tc
0000000   n   u   l   l  \r  \n
0000006
$ NO_COLOR=1 script -qec /home/stefan/g/jq/jq -n . /dev/null | od -tc
script: invalid option -- 'n'
Try 'script --help' for more information.
0000000
$ script --version
script from util-linux 2.33.1

@itchyny
Copy link
Contributor

itchyny commented Dec 20, 2023

$SHELL --version
export X=1; f() { printenv X; }; X=2 f

@polluks
Copy link
Contributor Author

polluks commented Dec 20, 2023

$ $SHELL --version
GNU bash, version 5.0.3(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
$ export X=1; f() { printenv X; }; X=2 f
2

@itchyny
Copy link
Contributor

itchyny commented Dec 20, 2023

Can you try with /bin/sh -c?
/bin/sh -xc 'NO_COLOR=1 script -qec "/home/stefan/g/jq/jq -n ." /dev/null | od -tc'

@polluks
Copy link
Contributor Author

polluks commented Dec 21, 2023

$ /bin/sh -xc 'NO_COLOR=1 script -qec "/home/stefan/g/jq/jq -n ." /dev/null | od -tc'
+ NO_COLOR=1 script -qec /home/stefan/g/jq/jq -n . /dev/null
+ od -tc
0000000   n   u   l   l  \r  \n
0000006

@itchyny
Copy link
Contributor

itchyny commented Dec 26, 2023

@polluks Did you find any other clue? You're the only one that can debug step by step so appreciated if you can find the cause yourself. Otherwise I'm thinking of closing this issue because there was no further context provided and the test implementation looks correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants