Skip to content

Commit e56737f

Browse files
committed
tools/vectorlint: enforce unique test group type
1 parent f4795eb commit e56737f

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

tools/vectorlint/main.go

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@ import (
77
"encoding/pem"
88
"flag"
99
"fmt"
10-
"github.com/santhosh-tekuri/jsonschema/v6"
1110
"io/fs"
1211
"log"
1312
"os"
1413
"path/filepath"
1514
"regexp"
1615
"strings"
16+
17+
"github.com/santhosh-tekuri/jsonschema/v6"
1718
)
1819

1920
var (
@@ -237,6 +238,7 @@ func lintVectorTestGroups(vectorData []byte, path string) error {
237238
var vector struct {
238239
NumberOfTests int `json:"numberOfTests"`
239240
TestGroups []struct {
241+
Type string `json:"type"`
240242
Tests []struct {
241243
TcId int `json:"tcId"`
242244
} `json:"tests"`
@@ -246,6 +248,22 @@ func lintVectorTestGroups(vectorData []byte, path string) error {
246248
return fmt.Errorf("error decoding vector JSON data for test groups: %w", err)
247249
}
248250

251+
// Within a vector file, all test groups must have the same type.
252+
testGroupTypes := make(map[string]bool)
253+
for _, tg := range vector.TestGroups {
254+
if tg.Type != "" {
255+
testGroupTypes[tg.Type] = true
256+
}
257+
}
258+
259+
if len(testGroupTypes) > 1 {
260+
var types []string
261+
for t := range testGroupTypes {
262+
types = append(types, t)
263+
}
264+
return fmt.Errorf("vector %q has multiple test group types: %v (expected only one type per file)", path, types)
265+
}
266+
249267
// Within a vector file, test case IDs must be unique.
250268
testCaseIds := make(map[int]struct{})
251269
for _, tg := range vector.TestGroups {

0 commit comments

Comments
 (0)