File tree Expand file tree Collapse file tree 5 files changed +86
-1
lines changed Expand file tree Collapse file tree 5 files changed +86
-1
lines changed Original file line number Diff line number Diff line change
1
+ name : Test
2
+
3
+ on :
4
+ push :
5
+ branches : main
6
+ pull_request :
7
+ jobs :
8
+ test :
9
+ runs-on : ubuntu-latest
10
+ steps :
11
+ - uses : actions/setup-go@v2
12
+ - uses : actions/checkout@v2
13
+ - run : |
14
+ go version
15
+ go mod download
16
+ go test
Original file line number Diff line number Diff line change @@ -104,7 +104,7 @@ func GetPackages(out string) Packages {
104
104
sort .Slice (packages , func (i , j int ) bool {
105
105
cmp := len (packages [i ].Tests ) - len (packages [j ].Tests )
106
106
if cmp != 0 {
107
- return cmp < 0
107
+ return cmp > 0
108
108
}
109
109
return strings .Compare (packages [i ].Name , packages [j ].Name ) < 0
110
110
})
Original file line number Diff line number Diff line change
1
+ package splittestgen_test
2
+
3
+ import (
4
+ "fmt"
5
+ "os/exec"
6
+ "strings"
7
+ "testing"
8
+ )
9
+
10
+ func TestRun (t * testing.T ) {
11
+ const total = 3
12
+ for _ , c := range []struct {
13
+ index int
14
+ expected string
15
+ }{
16
+ {
17
+ index : 0 ,
18
+ expected : "go test github.com/minoritea/go-splittestgen/testdata/group1 -run '^(?:Test1|Test2)$'" ,
19
+ },
20
+ {
21
+ index : 1 ,
22
+ expected : "go test github.com/minoritea/go-splittestgen/testdata/group1 -run '^(?:Test3|Test4)$'" ,
23
+ },
24
+ {
25
+ index : 2 ,
26
+ expected : "go test github.com/minoritea/go-splittestgen/testdata/group2 -run '^(?:TestCases)$'" ,
27
+ },
28
+ } {
29
+ index , expected := c .index , c .expected
30
+ t .Run (fmt .Sprintf ("case-of-index-%d" , index ), func (t * testing.T ) {
31
+ t .Parallel ()
32
+ output , err := exec .Command (
33
+ "sh" , "-c" , fmt .Sprintf (` \
34
+ (cd testdata && go test ./... -list .) | \
35
+ go run ./cmd/go-splittestgen -index %d -total %d \
36
+ ` , index , total ),
37
+ ).CombinedOutput ()
38
+
39
+ if err != nil {
40
+ t .Fatal (err )
41
+ }
42
+
43
+ if strings .TrimSpace (string (output )) != expected {
44
+ t .Log ("The actual output is\n " , string (output ))
45
+ t .Log ("The expected output is\n " , expected )
46
+ t .Fatal ("The command output is not equal to the expected value" )
47
+ }
48
+ })
49
+ }
50
+ }
Original file line number Diff line number Diff line change
1
+ package group1_test
2
+
3
+ import "testing"
4
+
5
+ func Test1 (t * testing.T ) { t .Log ("OK" ) }
6
+ func Test2 (t * testing.T ) { t .Log ("Also OK" ) }
7
+ func Test3 (t * testing.T ) { t .Log ("Also OK" ) }
8
+ func Test4 (t * testing.T ) { t .Log ("Also OK" ) }
Original file line number Diff line number Diff line change
1
+ package group2_test
2
+
3
+ import "testing"
4
+
5
+ func TestMain (m * testing.M ) { m .Run () }
6
+ func TestCases (t * testing.T ) {
7
+ cases := []string {"A" , "B" }
8
+ for _ , name := range cases {
9
+ t .Run ("case-" + name , func (t * testing.T ) { t .Logf ("Case %s is OK" , name ) })
10
+ }
11
+ }
You can’t perform that action at this time.
0 commit comments