Skip to content

Commit 70e45c8

Browse files
committed
fix(cli): use gray instead of faint for dim labels (#323)
SGR 2 (faint/dim) is not rendered by the GitHub Actions log UI, so keywords like `Expected`, `Tests:` and `Assertions:` appeared without any color in CI while looking dim locally. Switch the `_BASHUNIT_COLOR_FAINT` constant to SGR 90 (bright black / gray), which is widely supported across terminals and CI renderers. Closes #323
1 parent 8f5e672 commit 70e45c8

30 files changed

Lines changed: 142 additions & 133 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
- Parallel test execution is now enabled on Alpine Linux (#370)
1212

1313
### Fixed
14+
- Dim/faint labels now render as gray (SGR 90) so keywords like `Expected` and `Tests:` stay colored in GitHub Actions logs (#323)
1415
- Syntax error in a test file now fails the suite instead of passing silently (#220)
1516
- `--stop-on-failure` now stops on runtime errors such as `command not found` or `illegal option` (#383)
1617
- Spying on `echo` or `printf` no longer hangs via infinite recursion (#607)

src/colors.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ if bashunit::env::is_no_color_enabled; then
3737
_BASHUNIT_COLOR_DEFAULT=""
3838
else
3939
_BASHUNIT_COLOR_BOLD="$(bashunit::sgr 1)"
40-
_BASHUNIT_COLOR_FAINT="$(bashunit::sgr 2)"
40+
# Use SGR 90 (bright black / gray) instead of SGR 2 (faint), since
41+
# GitHub Actions' log renderer does not render the faint attribute.
42+
_BASHUNIT_COLOR_FAINT="$(bashunit::sgr 90)"
4143
_BASHUNIT_COLOR_BLACK="$(bashunit::sgr 30)"
4244
_BASHUNIT_COLOR_FAILED="$(bashunit::sgr 31)"
4345
_BASHUNIT_COLOR_PASSED="$(bashunit::sgr 32)"

tests/acceptance/bashunit_execution_error_test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ function test_bashunit_when_a_execution_error() {
1010
local test_file=./tests/acceptance/fixtures/test_bashunit_when_a_execution_error.sh
1111
local color_default="$(bashunit::sgr 0)"
1212
local color_bold="$(bashunit::sgr 1)"
13-
local color_dim="$(bashunit::sgr 2)"
13+
local color_dim="$(bashunit::sgr 90)"
1414
local color_red="$(bashunit::sgr 31)"
1515

1616
function format_summary_title() {
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
✗ Failed: assert same
2-
Expected 'foo'
3-
but got  'bar'
2+
Expected 'foo'
3+
but got  'bar'
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
✗ Failed: assert same
2-
Expected 'foo'
3-
but got  'bar'
2+
Expected 'foo'
3+
but got  'bar'
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
Running tests/acceptance/fixtures/test_bashunit_when_a_test_returns_non_zero.sh
22
✗ Error: Returns non zero
3-

3+

44

55
There was 1 failure:
66

77
|1) tests/acceptance/fixtures/test_bashunit_when_a_test_returns_non_zero.sh:3
88

9-
Tests:  1 failed, 1 total
10-
Assertions: 0 failed, 0 total
9+
Tests:  1 failed, 1 total
10+
Assertions: 0 failed, 0 total
1111

1212
 Some tests failed 

tests/acceptance/snapshots/bashunit_fail_test_sh.test_bashunit_when_a_test_fail_simple_output_env.snapshot

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44

55
|1) ./tests/acceptance/fixtures/test_bashunit_when_a_test_fail.sh:12
66
|✗ Failed: Assert failing
7-
| Expected '1'
8-
| but got  '0'
9-
| Source:
10-
| 13: assert_same 1 0
7+
| Expected '1'
8+
| but got  '0'
9+
| Source:
10+
| 13: assert_same 1 0
1111

1212

1313

14-
Tests:  4 passed, 1 failed, 5 total
15-
Assertions: 6 passed, 1 failed, 7 total
14+
Tests:  4 passed, 1 failed, 5 total
15+
Assertions: 6 passed, 1 failed, 7 total
1616

1717
 Some tests failed 

tests/acceptance/snapshots/bashunit_fail_test_sh.test_bashunit_when_a_test_fail_simple_output_option.snapshot

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44

55
|1) ./tests/acceptance/fixtures/test_bashunit_when_a_test_fail.sh:12
66
|✗ Failed: Assert failing
7-
| Expected '1'
8-
| but got  '0'
9-
| Source:
10-
| 13: assert_same 1 0
7+
| Expected '1'
8+
| but got  '0'
9+
| Source:
10+
| 13: assert_same 1 0
1111

1212

1313

14-
Tests:  4 passed, 1 failed, 5 total
15-
Assertions: 6 passed, 1 failed, 7 total
14+
Tests:  4 passed, 1 failed, 5 total
15+
Assertions: 6 passed, 1 failed, 7 total
1616

1717
 Some tests failed 

tests/acceptance/snapshots/bashunit_fail_test_sh.test_bashunit_when_a_test_fail_verbose_output_env.snapshot

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@
22
✓ Passed: Assert same
33
✓ Passed: Assert contains
44
✗ Failed: Assert failing
5-
Expected '1'
6-
but got  '0'
5+
Expected '1'
6+
but got  '0'
77
✓ Passed: Assert greater and less than
88
✓ Passed: Assert empty
99

1010
There was 1 failure:
1111

1212
|1) ./tests/acceptance/fixtures/test_bashunit_when_a_test_fail.sh:12
1313
|✗ Failed: Assert failing
14-
| Expected '1'
15-
| but got  '0'
16-
| Source:
17-
| 13: assert_same 1 0
14+
| Expected '1'
15+
| but got  '0'
16+
| Source:
17+
| 13: assert_same 1 0
1818

19-
Tests:  4 passed, 1 failed, 5 total
20-
Assertions: 6 passed, 1 failed, 7 total
19+
Tests:  4 passed, 1 failed, 5 total
20+
Assertions: 6 passed, 1 failed, 7 total
2121

2222
 Some tests failed 

tests/acceptance/snapshots/bashunit_fail_test_sh.test_bashunit_when_a_test_fail_verbose_output_option.snapshot

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@
22
✓ Passed: Assert same
33
✓ Passed: Assert contains
44
✗ Failed: Assert failing
5-
Expected '1'
6-
but got  '0'
5+
Expected '1'
6+
but got  '0'
77
✓ Passed: Assert greater and less than
88
✓ Passed: Assert empty
99

1010
There was 1 failure:
1111

1212
|1) ./tests/acceptance/fixtures/test_bashunit_when_a_test_fail.sh:12
1313
|✗ Failed: Assert failing
14-
| Expected '1'
15-
| but got  '0'
16-
| Source:
17-
| 13: assert_same 1 0
14+
| Expected '1'
15+
| but got  '0'
16+
| Source:
17+
| 13: assert_same 1 0
1818

19-
Tests:  4 passed, 1 failed, 5 total
20-
Assertions: 6 passed, 1 failed, 7 total
19+
Tests:  4 passed, 1 failed, 5 total
20+
Assertions: 6 passed, 1 failed, 7 total
2121

2222
 Some tests failed 

0 commit comments

Comments
 (0)