Skip to content

Commit de1bcdb

Browse files
committed
Change how test-cli is running
The cli-test is in the tests directory. It is a separate go module, because we don't want it to run with the unit tests when running go test ./... But this approach causes issues with automatic update of dependencies, because the go.mod in the tests directory does not get automatic updates, and then fauls in CI. Instead, this commit changes the cli-test to only run if the RUN_CLI_TESTS environment variable is set to "true". In addition, this commit stopped using the deprecated testscript.RunMain function, and replaces it with the recommended testscript.Main function.
1 parent 789e9e9 commit de1bcdb

File tree

5 files changed

+8
-49
lines changed

5 files changed

+8
-49
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ build-for-linux:
2424
build-all: build build-for-linux build-for-mac build-for-windows
2525

2626
test-cli:
27-
cd tests; go test -v ./
27+
RUN_CLI_TESTS=true go test -v ./tests/...
2828

2929
test: unit-test test-cli
3030

cmd/ginkgolinter/cli/cli.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"github.com/nunnatsa/ginkgolinter/version"
1212
)
1313

14-
func Main() int {
14+
func Main() {
1515
if len(os.Args) == 2 && os.Args[1] == "version" {
1616
fmt.Printf("ginkgolinter version: %s\n", version.Version())
1717
fmt.Printf("git hash: %s\n", version.GitHash())
@@ -20,6 +20,4 @@ func Main() int {
2020
}
2121

2222
singlechecker.Main(ginkgolinter.NewAnalyzer())
23-
24-
return 0
2523
}

tests/cli_test.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,16 @@ func TestMain(m *testing.M) {
2121
panic(err)
2222
}
2323

24-
os.Exit(testscript.RunMain(m, map[string]func() int{
24+
testscript.Main(m, map[string]func(){
2525
"ginkgolinter": cli.Main,
26-
}))
26+
})
2727
}
2828

2929
func TestCli(t *testing.T) {
30+
if os.Getenv("RUN_CLI_TESTS") != "true" {
31+
t.Skipf(`Skipping CLI tests. These tests are not unit tests, but more like integration tests.
32+
The tests will run when the RUN_CLI_TESTS environment variable is set to "true"`)
33+
}
3034
pwd, err := os.Getwd()
3135
if err != nil {
3236
panic(err)

tests/go.mod

Lines changed: 0 additions & 19 deletions
This file was deleted.

tests/go.sum

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)