Skip to content

fix: make test suite stable when NO_COLOR is set - #1449

Merged
mrexox merged 1 commit into
evilmartians:masterfrom
viralpraxis:make-tests-stable-with-no-color
Jun 19, 2026
Merged

fix: make test suite stable when NO_COLOR is set#1449
mrexox merged 1 commit into
evilmartians:masterfrom
viralpraxis:make-tests-stable-with-no-color

Conversation

@viralpraxis

Copy link
Copy Markdown
Member
$ env NO_COLOR=1 make test
go test -cpu 24 -race -count=1 -timeout=30s ./...
?   	github.com/evilmartians/lefthook/v2	[no test files]
?   	github.com/evilmartians/lefthook/v2/cmd	[no test files]
?   	github.com/evilmartians/lefthook/v2/gen	[no test files]
ok  	github.com/evilmartians/lefthook/v2/internal/command	1.081s
ok  	github.com/evilmartians/lefthook/v2/internal/config	1.050s
ok  	github.com/evilmartians/lefthook/v2/internal/git	1.018s
?   	github.com/evilmartians/lefthook/v2/internal/logger	[no test files]
?   	github.com/evilmartians/lefthook/v2/internal/run	[no test files]
--- FAIL: Test_guard_wrap (0.00s)
    --- FAIL: Test_guard_wrap/stashUnstagedChanges=true_failOnChanges=true_with_partially_staged_and_hook_changes_with_diff (0.00s)
        commander.go:122: 9) expected: 'git diff --color -- file1', called: 'git diff -- file1'
    --- FAIL: Test_guard_wrap/failOnChanges=true_fail_with_changeset_different_with_diff (0.00s)
        commander.go:122: 4) expected: 'git diff --color -- file1 file2', called: 'git diff -- file1 file2'
FAIL
FAIL	github.com/evilmartians/lefthook/v2/internal/run/controller	0.039s
?   	github.com/evilmartians/lefthook/v2/internal/run/controller/command	[no test files]
ok  	github.com/evilmartians/lefthook/v2/internal/run/controller/command/replacer	1.016s
ok  	github.com/evilmartians/lefthook/v2/internal/run/controller/exec	1.658s
ok  	github.com/evilmartians/lefthook/v2/internal/run/controller/filter	1.015s
ok  	github.com/evilmartians/lefthook/v2/internal/run/controller/utils	1.010s
ok  	github.com/evilmartians/lefthook/v2/internal/run/result	1.020s
ok  	github.com/evilmartians/lefthook/v2/internal/system	1.012s
?   	github.com/evilmartians/lefthook/v2/internal/templates	[no test files]
ok  	github.com/evilmartians/lefthook/v2/internal/updater	1.028s
ok  	github.com/evilmartians/lefthook/v2/internal/version	1.016s
ok  	github.com/evilmartians/lefthook/v2/tests/helpers/cmdtest	1.014s
ok  	github.com/evilmartians/lefthook/v2/tests/helpers/configtest	1.016s
ok  	github.com/evilmartians/lefthook/v2/tests/helpers/gittest	1.017s
?   	github.com/evilmartians/lefthook/v2/tests/helpers/loggertest	[no test files]
FAIL
make: *** [Makefile:25: test] Error 1

@viralpraxis viralpraxis self-assigned this Jun 18, 2026
@viralpraxis
viralpraxis requested a review from mrexox as a code owner June 18, 2026 14:15

@mrexox mrexox left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! I would appreciate a comment in loggertest.go explaining why we disable colors there.

```shell
$ env NO_COLOR=1 make test
go test -cpu 24 -race -count=1 -timeout=30s ./...
?   	github.com/evilmartians/lefthook/v2	[no test files]
?   	github.com/evilmartians/lefthook/v2/cmd	[no test files]
?   	github.com/evilmartians/lefthook/v2/gen	[no test files]
ok  	github.com/evilmartians/lefthook/v2/internal/command	1.081s
ok  	github.com/evilmartians/lefthook/v2/internal/config	1.050s
ok  	github.com/evilmartians/lefthook/v2/internal/git	1.018s
?   	github.com/evilmartians/lefthook/v2/internal/logger	[no test files]
?   	github.com/evilmartians/lefthook/v2/internal/run	[no test files]
--- FAIL: Test_guard_wrap (0.00s)
    --- FAIL: Test_guard_wrap/stashUnstagedChanges=true_failOnChanges=true_with_partially_staged_and_hook_changes_with_diff (0.00s)
        commander.go:122: 9) expected: 'git diff --color -- file1', called: 'git diff -- file1'
    --- FAIL: Test_guard_wrap/failOnChanges=true_fail_with_changeset_different_with_diff (0.00s)
        commander.go:122: 4) expected: 'git diff --color -- file1 file2', called: 'git diff -- file1 file2'
FAIL
FAIL	github.com/evilmartians/lefthook/v2/internal/run/controller	0.039s
?   	github.com/evilmartians/lefthook/v2/internal/run/controller/command	[no test files]
ok  	github.com/evilmartians/lefthook/v2/internal/run/controller/command/replacer	1.016s
ok  	github.com/evilmartians/lefthook/v2/internal/run/controller/exec	1.658s
ok  	github.com/evilmartians/lefthook/v2/internal/run/controller/filter	1.015s
ok  	github.com/evilmartians/lefthook/v2/internal/run/controller/utils	1.010s
ok  	github.com/evilmartians/lefthook/v2/internal/run/result	1.020s
ok  	github.com/evilmartians/lefthook/v2/internal/system	1.012s
?   	github.com/evilmartians/lefthook/v2/internal/templates	[no test files]
ok  	github.com/evilmartians/lefthook/v2/internal/updater	1.028s
ok  	github.com/evilmartians/lefthook/v2/internal/version	1.016s
ok  	github.com/evilmartians/lefthook/v2/tests/helpers/cmdtest	1.014s
ok  	github.com/evilmartians/lefthook/v2/tests/helpers/configtest	1.016s
ok  	github.com/evilmartians/lefthook/v2/tests/helpers/gittest	1.017s
?   	github.com/evilmartians/lefthook/v2/tests/helpers/loggertest	[no test files]
FAIL
make: *** [Makefile:25: test] Error 1
```
@viralpraxis
viralpraxis force-pushed the make-tests-stable-with-no-color branch from bde01d9 to 3b6170b Compare June 19, 2026 11:32
@viralpraxis

Copy link
Copy Markdown
Member Author

Thank you! I would appreciate a comment in loggertest.go explaining why we disable colors there.

Done.

@mrexox mrexox changed the title Make test suite stable when NO_COLOR is set fix: make test suite stable when NO_COLOR is set Jun 19, 2026
@mrexox
mrexox merged commit cbfb4a5 into evilmartians:master Jun 19, 2026
13 of 14 checks passed
@viralpraxis
viralpraxis deleted the make-tests-stable-with-no-color branch June 19, 2026 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants