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
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,6 @@ github.com/kaptinlin/go-i18n v0.1.4 h1:wCiwAn1LOcvymvWIVAM4m5dUAMiHunTdEubLDk4hT
github.com/kaptinlin/go-i18n v0.1.4/go.mod h1:g1fn1GvTgT4CiLE8/fFE1hboHWJ6erivrDpiDtCcFKg=
github.com/kaptinlin/jsonschema v0.4.6 h1:vOSFg5tjmfkOdKg+D6Oo4fVOM/pActWu/ntkPsI1T64=
github.com/kaptinlin/jsonschema v0.4.6/go.mod h1:1DUd7r5SdyB2ZnMtyB7uLv64dE3zTFTiYytDCd+AEL0=
github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo=
github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ=
github.com/klauspost/compress v1.18.7 h1:aUyZsS4kH3QTKurYhAOwAHxllVPnOthb3vPfnF1Ehjw=
github.com/klauspost/compress v1.18.7/go.mod h1:cwPg85FWrGar70rWktvGQj8/hthj3wpl0PGDogxkrSQ=
github.com/knadh/koanf/maps v0.1.2 h1:RBfmAW5CnZT+PJ1CVc1QSJKf4Xu9kxfQgYVQSu8hpbo=
Expand Down
5 changes: 2 additions & 3 deletions test/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package test

import (
"errors"
"fmt"
"os"
"path"

Expand Down Expand Up @@ -37,9 +38,7 @@ func GetTestsFromFiles(globPattern string) ([]*FTWTest, error) {
}
ftwTest, err := GetTestFromYaml(yamlString, fileName)
if err != nil {
log.Warn().Msgf("Problem detected in file %s:\n%v\n",
filePath, err)
continue
return tests, fmt.Errorf("problem detected in file %s: %w", filePath, err)
}

tests = append(tests, ftwTest)
Expand Down
14 changes: 14 additions & 0 deletions test/files_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,17 @@ func (s *filesTestSuite) TestGetFromBadYAML() {

s.Error(err, "reading yaml should fail")
}

// A single unparseable file must fail the whole run, even when other files in
// the glob parse fine. Skipping it silently hides the loss of test coverage.
func (s *filesTestSuite) TestGetFromBadYAMLAmongGoodFiles() {
_, err := utils.CreateTempFileWithContent(s.tempDir, yamlTest, "good-*.yaml")
s.Require().NoError(err)
bad, err := utils.CreateTempFileWithContent(s.tempDir, wrongYamlTest, "bad-*.yaml")
s.Require().NoError(err)

_, err = GetTestsFromFiles(s.tempDir + "/*.yaml")

s.Require().Error(err, "an unparseable file must not be skipped")
s.Contains(err.Error(), bad, "error should name the offending file")
}