Improve reliability of NO_COLOR tests. (#3188)
* Improve reliability of NO_COLOR tests. Use `env` to ensure that `NO_COLOR` is set to the desired value regardless of any initialization that may occur when `script` forks a shell to run jq in. Note that `env -u` is not portable, so there is no good solution for the first test case. * Always use /bin/sh, not the user's login shell.
This commit is contained in:
1 parent
32a304b912
commit
3c5707f7fb
1 file changed
+6
-3
+6
-3
@@ -14,6 +14,9 @@ JQ="$JQ -b"
|
|||||||
|
|
||||||
PATH=$JQBASEDIR:$PATH $JQBASEDIR/tests/jq-f-test.sh > /dev/null
|
PATH=$JQBASEDIR:$PATH $JQBASEDIR/tests/jq-f-test.sh > /dev/null
|
||||||
|
|
||||||
|
SHELL=/bin/sh
|
||||||
|
export SHELL
|
||||||
|
|
||||||
if [ -f "$JQBASEDIR/.libs/libinject_errors.so" ]; then
|
if [ -f "$JQBASEDIR/.libs/libinject_errors.so" ]; then
|
||||||
# Do some simple error injection tests to check that we're handling
|
# Do some simple error injection tests to check that we're handling
|
||||||
# I/O errors correctly.
|
# I/O errors correctly.
|
||||||
@@ -608,17 +611,17 @@ if $test_no_color && command -v script >/dev/null 2>&1; then
|
|||||||
od -tc $d/expect
|
od -tc $d/expect
|
||||||
od -tc $d/color
|
od -tc $d/color
|
||||||
cmp $d/color $d/expect
|
cmp $d/color $d/expect
|
||||||
NO_COLOR= faketty $JQ_NO_B -n . > $d/color
|
faketty env NO_COLOR= $JQ_NO_B -n . > $d/color
|
||||||
printf '\033[0;90mnull\033[0m\r\n' > $d/expect
|
printf '\033[0;90mnull\033[0m\r\n' > $d/expect
|
||||||
od -tc $d/expect
|
od -tc $d/expect
|
||||||
od -tc $d/color
|
od -tc $d/color
|
||||||
cmp $d/color $d/expect
|
cmp $d/color $d/expect
|
||||||
NO_COLOR=1 faketty $JQ_NO_B -n . > $d/color
|
faketty env NO_COLOR=1 $JQ_NO_B -n . > $d/color
|
||||||
printf 'null\r\n' > $d/expect
|
printf 'null\r\n' > $d/expect
|
||||||
od -tc $d/expect
|
od -tc $d/expect
|
||||||
od -tc $d/color
|
od -tc $d/color
|
||||||
cmp $d/color $d/expect
|
cmp $d/color $d/expect
|
||||||
NO_COLOR=1 faketty $JQ_NO_B -Cn . > $d/color
|
faketty env NO_COLOR=1 $JQ_NO_B -Cn . > $d/color
|
||||||
printf '\033[0;90mnull\033[0m\r\n' > $d/expect
|
printf '\033[0;90mnull\033[0m\r\n' > $d/expect
|
||||||
od -tc $d/expect
|
od -tc $d/expect
|
||||||
od -tc $d/color
|
od -tc $d/color
|
||||||
|
|||||||
Reference in new issue
Block a user