forked from bazelbuild/bazelisk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bazelisk_test.go
49 lines (46 loc) · 1.26 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
48
49
package main
import (
"fmt"
"io/ioutil"
"sort"
"testing"
"github.com/bazelbuild/rules_go/go/tools/bazel"
)
func TestScanIssuesForIncompatibleFlags(t *testing.T) {
path, err := bazel.Runfile("sample-issues-migration.json")
if err != nil {
t.Errorf("Can not load sample github issues")
}
samplesJSON, err := ioutil.ReadFile(path)
if err != nil {
t.Errorf("Can not load sample github issues")
}
flags, err := scanIssuesForIncompatibleFlags(samplesJSON)
if flags == nil {
t.Errorf("Could not parse sample issues")
}
expected_flagnames := []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 got_flags []string
for _, flag := range flags {
fmt.Printf("%s\n", flag.String())
got_flags = append(got_flags, flag.Name)
}
sort.Strings(got_flags)
mismatch := false
for i, got := range got_flags {
if expected_flagnames[i] != got {
mismatch = true
break
}
}
if mismatch || len(expected_flagnames) != len(got_flags) {
t.Errorf("Expected %s, got %s", expected_flagnames, got_flags)
}
}