aboutsummaryrefslogtreecommitdiffstats
path: root/android/testing.go
diff options
context:
space:
mode:
Diffstat (limited to 'android/testing.go')
-rw-r--r--android/testing.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/android/testing.go b/android/testing.go
index 6e80c532..f5d33e11 100644
--- a/android/testing.go
+++ b/android/testing.go
@@ -17,6 +17,7 @@ package android
import (
"fmt"
"path/filepath"
+ "regexp"
"strings"
"testing"
@@ -163,3 +164,26 @@ func FailIfErrored(t *testing.T, errs []error) {
t.FailNow()
}
}
+
+func FailIfNoMatchingErrors(t *testing.T, pattern string, errs []error) {
+ t.Helper()
+
+ matcher, err := regexp.Compile(pattern)
+ if err != nil {
+ t.Errorf("failed to compile regular expression %q because %s", pattern, err)
+ }
+
+ found := false
+ for _, err := range errs {
+ if matcher.FindStringIndex(err.Error()) != nil {
+ found = true
+ break
+ }
+ }
+ if !found {
+ t.Errorf("missing the expected error %q (checked %d error(s))", pattern, len(errs))
+ for i, err := range errs {
+ t.Errorf("errs[%d] = %s", i, err)
+ }
+ }
+}