Skip to content

Commit 4537e9d

Browse files
Implemented --check-documents flag in test subcommand (#339)
1 parent ba7cc5f commit 4537e9d

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

cmd/scip/main_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,12 +205,12 @@ func TestSCIPTests(t *testing.T) {
205205
}
206206

207207
var passOutput bytes.Buffer
208-
err := testMain(subtestDir, passFiles, index, "#", &passOutput)
208+
err := testMain(subtestDir, passFiles, false, index, "#", &passOutput)
209209
require.NoError(t, err)
210210
testCase.passOutput.Equal(t, passOutput.String())
211211

212212
var failOutput bytes.Buffer
213-
err = testMain(subtestDir, failFiles, index, "#", &failOutput)
213+
err = testMain(subtestDir, failFiles, false, index, "#", &failOutput)
214214
require.Error(t, err)
215215
testCase.failOutput.Equal(t, failOutput.String())
216216
})

cmd/scip/test.go

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@ import (
1515
)
1616

1717
type testFlags struct {
18-
from string // default: 'index.scip'
19-
commentSyntax string // default: '//'
20-
pathFilters cli.StringSlice
18+
from string // default: 'index.scip'
19+
commentSyntax string // default: '//'
20+
pathFilters cli.StringSlice
21+
checkDocuments bool // default: false
2122
}
2223

2324
func testCommand() cli.Command {
2425
var testFlags testFlags
26+
2527
test := cli.Command{
2628
Name: "test",
2729
Usage: "Validate a SCIP index against test files",
@@ -46,6 +48,12 @@ use the 'snapshot' subcommand.`, version),
4648
Usage: "Explicit list of test files to check. Can be specified multiple times. If not specified, all files are tested.",
4749
Destination: &testFlags.pathFilters,
4850
},
51+
&cli.BoolFlag{
52+
Name: "check-documents",
53+
Usage: "Whether or not to validate whether every file in the test directory has a correlating document in the SCIP index.",
54+
Destination: &testFlags.checkDocuments,
55+
Value: false,
56+
},
4957
},
5058
Action: func(c *cli.Context) error {
5159
dir := c.Args().Get(0)
@@ -55,7 +63,7 @@ use the 'snapshot' subcommand.`, version),
5563
return err
5664
}
5765

58-
return testMain(dir, testFlags.pathFilters.Value(), index, testFlags.commentSyntax, os.Stdout)
66+
return testMain(dir, testFlags.pathFilters.Value(), testFlags.checkDocuments, index, testFlags.commentSyntax, os.Stdout)
5967
},
6068
}
6169
return test
@@ -64,6 +72,7 @@ use the 'snapshot' subcommand.`, version),
6472
func testMain(
6573
directory string,
6674
fileFilters []string,
75+
checkDocuments bool,
6776
index *scip.Index,
6877
commentSyntax string,
6978
output io.Writer,
@@ -150,7 +159,7 @@ func testMain(
150159
}
151160
}
152161

153-
if len(allTestFilesSet) > 0 {
162+
if checkDocuments && len(allTestFilesSet) > 0 {
154163
sortedFiles := []string{}
155164
for f, _ := range allTestFilesSet {
156165
sortedFiles = append(sortedFiles, f)

0 commit comments

Comments
 (0)