From 05952d16e73e518ddfc5441cc4e8eedff6306bd5 Mon Sep 17 00:00:00 2001 From: Scott Nichols Date: Tue, 5 May 2020 14:08:36 -0700 Subject: [PATCH] log the error for parse test. Signed-off-by: Scott Nichols --- parser/local_parse_test.go | 2 +- parser/parse.go | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/parser/local_parse_test.go b/parser/local_parse_test.go index 1f8d3187..25d46345 100644 --- a/parser/local_parse_test.go +++ b/parser/local_parse_test.go @@ -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) } } diff --git a/parser/parse.go b/parser/parse.go index 377fbb6c..92cf42d3 100644 --- a/parser/parse.go +++ b/parser/parse.go @@ -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())