Skip to content

Commit

Permalink
log the error for parse test.
Browse files Browse the repository at this point in the history
Signed-off-by: Scott Nichols <[email protected]>
  • Loading branch information
Scott Nichols committed May 5, 2020
1 parent 99577d1 commit 05952d1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion parser/local_parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func TestImportBuildPackage(t *testing.T) {
func TestIsErrPackageNotFound(t *testing.T) {
b := New()
if _, err := b.importBuildPackage("fake/empty"); !isErrPackageNotFound(err) {
t.Fatal(err)
t.Errorf("expected error like %s, but got %v", regexErrPackageNotFound.String(), err)
}
}

Expand Down
3 changes: 2 additions & 1 deletion parser/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,8 @@ func (b *Builder) addDir(dir string, userRequested bool) error {
return nil
}

var regexErrPackageNotFound = regexp.MustCompile(`^unable to import ".*?": .*? does not contain package .*?`)
// regexErrPackageNotFound helps test the expected error for not finding a package.
var regexErrPackageNotFound = regexp.MustCompile(`^unable to import ".*?":.*`)

func isErrPackageNotFound(err error) bool {
return regexErrPackageNotFound.MatchString(err.Error())
Expand Down

0 comments on commit 05952d1

Please sign in to comment.