File tree Expand file tree Collapse file tree 5 files changed +30
-7
lines changed Expand file tree Collapse file tree 5 files changed +30
-7
lines changed Original file line number Diff line number Diff line change 1+ name : bash_unit CI
2+ on :
3+ push :
4+
5+ jobs :
6+ ubuntu :
7+ runs-on : ubuntu-latest
8+ steps :
9+ - uses : actions/checkout@v2
10+ - name : Unit testing with bash_unit
11+ run : FORCE_COLOR=true ./bash_unit tests/test*
Original file line number Diff line number Diff line change @@ -111,6 +111,7 @@ Running tests in tests/test_core.sh
111111 Running test_fake_echo_stdin_when_no_params ... SUCCESS ✓
112112 Running test_fake_exports_faked_in_subshells ... SUCCESS ✓
113113 Running test_fake_transmits_params_to_fake_code ... SUCCESS ✓
114+ Running test_should_pretty_format_even_when_LANG_is_unset ... SUCCESS ✓
114115Overall result: SUCCESS ✓
115116```
116117
@@ -174,6 +175,7 @@ ok ✓ test_fake_can_fake_inline
174175ok ✓ test_fake_echo_stdin_when_no_params
175176ok ✓ test_fake_exports_faked_in_subshells
176177ok ✓ test_fake_transmits_params_to_fake_code
178+ ok - test_should_pretty_format_even_when_LANG_is_unset
177179```
178180
179181== How to write tests
Original file line number Diff line number Diff line change @@ -243,9 +243,10 @@ pretty_failure() {
243243pretty_format () {
244244 local color=" $1 "
245245 local pretty_symbol=" $2 "
246- local alt_symbol=" $3 "
246+ local alt_symbol=" ${3 :- } "
247247 local term_utf8=false
248- if is_terminal && [[ " $LANG " =~ .* UTF-8.* ]]
248+ # env
249+ if is_terminal && [[ " ${LANG:- } " =~ .* UTF-8.* ]]
249250 then
250251 term_utf8=true
251252 fi
@@ -280,7 +281,7 @@ color() {
280281}
281282
282283is_terminal () {
283- [ -t 1 ] || [[ " ${FORCE_COLOR} " == true ]]
284+ [ -t 1 ] || [[ " ${FORCE_COLOR:- } " == true ]]
284285}
285286
286287text_format () {
Original file line number Diff line number Diff line change 150150 assert_equals 2 $( ps | " $GREP " pts | wc -l)
151151}
152152
153+ test_should_pretty_format_even_when_LANG_is_unset () {
154+ # See https://github.com/pgrange/bash_unit/pull/81
155+ unset LANG
156+ assert " echo foo | pretty_format GREEN I"
157+ }
158+
153159if [[ " ${STICK_TO_CWD} " != true ]]
154160then
155161 # do not test for cwd if STICK_TO_CWD is true
Original file line number Diff line number Diff line change @@ -4,10 +4,8 @@ TEST_PATTERN='```test'
44OUTPUT_PATTERN=' ```output'
55LANG=C.UTF-8
66
7- export FORCE_COLOR=false
87export STICK_TO_CWD=true
9- BASH_UNIT=" eval ./bash_unit"
10- # BASH_UNIT="eval FORCE_COLOR=false ./bash_unit"
8+ BASH_UNIT=" eval FORCE_COLOR=false ./bash_unit"
119
1210prepare_tests () {
1311 mkdir /tmp/$$
@@ -21,14 +19,19 @@ prepare_tests() {
2119 while grep -E ' ^' " $TEST_PATTERN " ' $' $remaining > /dev/null
2220 do
2321 (( ++ block))
24- run_doc_test $remaining $swap | & sed ' $a\' > $test_output$block
22+ run_doc_test $remaining $swap | & sed ' $a\' | work_around_github_action_problem > $test_output$block
2523 doc_to_output $remaining $swap > $expected_output$block
2624 eval ' function test_block_' " $( printf %02d $block)"' () {
2725 assert " diff -u '" $expected_output$block " ' '" $test_output$block " '"
2826 }'
2927 done
3028}
3129
30+ work_around_github_action_problem() {
31+ # I have no idea what is happening with these broken pipes on github actions
32+ grep -v ' ^/usr/bin/grep: write error: Broken pipe$'
33+ }
34+
3235function run_doc_test() {
3336 local remaining="$1"
3437 local swap="$2"
You can’t perform that action at this time.
0 commit comments