Skip to content
Myr

Improve reliability of NO_COLOR tests. (#3188)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* 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.

authored by Dag-Erling Smørgrav · committed by GitHub · parent 32a304b · Browse files · 1 file+6 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+6 added−3 removed

  • tests:+6 added−3 removed

1 file+6 added−3 removed

modified:tests/shtest+6 added-3 removed
12 unmodified lines
13JQ="$JQ -b"1415PATH=$JQBASEDIR:$PATH $JQBASEDIR/tests/jq-f-test.sh > /dev/null1617SHELL=/bin/sh18export SHELL1920if [ -f "$JQBASEDIR/.libs/libinject_errors.so" ]; then21 # Do some simple error injection tests to check that we're handling22 # I/O errors correctly.23 (
586 unmodified lines
610 printf '\033[0;90mnull\033[0m\r\n' > $d/expect611 od -tc $d/expect612 od -tc $d/color613 cmp $d/color $d/expect611 NO_COLOR= faketty $JQ_NO_B -n . > $d/color614 faketty env NO_COLOR= $JQ_NO_B -n . > $d/color615 printf '\033[0;90mnull\033[0m\r\n' > $d/expect616 od -tc $d/expect617 od -tc $d/color618 cmp $d/color $d/expect616 NO_COLOR=1 faketty $JQ_NO_B -n . > $d/color619 faketty env NO_COLOR=1 $JQ_NO_B -n . > $d/color620 printf 'null\r\n' > $d/expect621 od -tc $d/expect622 od -tc $d/color623 cmp $d/color $d/expect621 NO_COLOR=1 faketty $JQ_NO_B -Cn . > $d/color624 faketty env NO_COLOR=1 $JQ_NO_B -Cn . > $d/color625 printf '\033[0;90mnull\033[0m\r\n' > $d/expect626 od -tc $d/expect627 od -tc $d/color628 cmp $d/color $d/expect
100 unmodified lines