forked from bazelbuild/bazelisk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbazelisk_test.go
47 lines (43 loc) · 1.22 KB
/
bazelisk_test.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
42
43
44
45
46
47
package main
import (
"fmt"
"sort"
"testing"
"github.com/bazelbuild/bazelisk/core"
"github.com/bazelbuild/bazelisk/runfiles"
)
func TestScanIssuesForIncompatibleFlags(t *testing.T) {
samplesJSON, err := runfiles.ReadFile("sample-issues-migration.json")
if err != nil {
t.Errorf("Can not load sample github issues")
}
issues, err := core.ParseIssues(samplesJSON)
if err != nil {
t.Errorf("Can not parse sample github issues: %v", err)
}
flags := core.ScanIssuesForIncompatibleFlags(issues)
expectedFlagnames := []string{
"--//some/path:incompatible_user_defined_flag",
"--incompatible_always_check_depset_elements",
"--incompatible_no_implicit_file_export",
"--incompatible_remove_enabled_toolchain_types",
"--incompatible_remove_ram_utilization_factor",
"--incompatible_validate_top_level_header_inclusions",
}
var gotFlags []string
for _, flag := range flags {
fmt.Printf("%s\n", flag.String())
gotFlags = append(gotFlags, flag.Name)
}
sort.Strings(gotFlags)
mismatch := false
for i, got := range gotFlags {
if expectedFlagnames[i] != got {
mismatch = true
break
}
}
if mismatch || len(expectedFlagnames) != len(gotFlags) {
t.Errorf("Expected %s, got %s", expectedFlagnames, gotFlags)
}
}