-
Notifications
You must be signed in to change notification settings - Fork 286
/
list.go
41 lines (34 loc) · 981 Bytes
/
list.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package e2e
import (
"bufio"
"context"
"fmt"
"path/filepath"
"strings"
"github.com/aws/eks-anywhere/pkg/executables"
"github.com/aws/eks-anywhere/pkg/types"
)
func listTests(regex string, testsToSkip []string) (tests, skippedTests []string, err error) {
e := executables.NewExecutable(filepath.Join("bin", e2eBinary))
ctx := context.Background()
testResponse, err := e.Execute(ctx, "-test.list", regex)
if err != nil {
return nil, nil, fmt.Errorf("failed listing test from e2e binary: %v", err)
}
skipLookup := types.SliceToLookup(testsToSkip)
scanner := bufio.NewScanner(&testResponse)
for scanner.Scan() {
line := scanner.Text()
if skipLookup.IsPresent(line) {
skippedTests = append(skippedTests, line)
continue
}
if strings.HasPrefix(line, "Test") {
tests = append(tests, line)
}
}
if err := scanner.Err(); err != nil {
return nil, nil, fmt.Errorf("failed reading e2e list response: %v", err)
}
return tests, skippedTests, nil
}