Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmd/scip/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,12 +205,12 @@ func TestSCIPTests(t *testing.T) {
}

var passOutput bytes.Buffer
err := testMain(subtestDir, passFiles, index, "#", &passOutput)
err := testMain(subtestDir, passFiles, false, index, "#", &passOutput)
require.NoError(t, err)
testCase.passOutput.Equal(t, passOutput.String())

var failOutput bytes.Buffer
err = testMain(subtestDir, failFiles, index, "#", &failOutput)
err = testMain(subtestDir, failFiles, false, index, "#", &failOutput)
require.Error(t, err)
testCase.failOutput.Equal(t, failOutput.String())
})
Expand Down
19 changes: 14 additions & 5 deletions cmd/scip/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ import (
)

type testFlags struct {
from string // default: 'index.scip'
commentSyntax string // default: '//'
pathFilters cli.StringSlice
from string // default: 'index.scip'
commentSyntax string // default: '//'
pathFilters cli.StringSlice
checkDocuments bool // default: false
}

func testCommand() cli.Command {
var testFlags testFlags

test := cli.Command{
Name: "test",
Usage: "Validate a SCIP index against test files",
Expand All @@ -46,6 +48,12 @@ use the 'snapshot' subcommand.`, version),
Usage: "Explicit list of test files to check. Can be specified multiple times. If not specified, all files are tested.",
Destination: &testFlags.pathFilters,
},
&cli.BoolFlag{
Name: "check-documents",
Usage: "Whether or not to validate whether every file in the test directory has a correlating document in the SCIP index.",
Destination: &testFlags.checkDocuments,
Value: false,
},
},
Action: func(c *cli.Context) error {
dir := c.Args().Get(0)
Expand All @@ -55,7 +63,7 @@ use the 'snapshot' subcommand.`, version),
return err
}

return testMain(dir, testFlags.pathFilters.Value(), index, testFlags.commentSyntax, os.Stdout)
return testMain(dir, testFlags.pathFilters.Value(), testFlags.checkDocuments, index, testFlags.commentSyntax, os.Stdout)
},
}
return test
Expand All @@ -64,6 +72,7 @@ use the 'snapshot' subcommand.`, version),
func testMain(
directory string,
fileFilters []string,
checkDocuments bool,
index *scip.Index,
commentSyntax string,
output io.Writer,
Expand Down Expand Up @@ -150,7 +159,7 @@ func testMain(
}
}

if len(allTestFilesSet) > 0 {
if checkDocuments && len(allTestFilesSet) > 0 {
sortedFiles := []string{}
for f, _ := range allTestFilesSet {
sortedFiles = append(sortedFiles, f)
Expand Down