Merge changes I406c5bef,Ibde685d7,I1c09412d am: 45d4f09f2f

am: 6eaae1a84a

Change-Id: I1cf47a14f8245d01a783d98cff0c2fec46e1193b
This commit is contained in:
Logan Chien
2018-03-16 02:19:45 +00:00
committed by android-build-merger
10 changed files with 274 additions and 94 deletions

View File

@@ -22,7 +22,6 @@ import (
"io/ioutil"
"os"
"reflect"
"regexp"
"sort"
"strings"
"testing"
@@ -147,9 +146,9 @@ func testCcWithConfig(t *testing.T, bp string, config android.Config) *android.T
ctx := createTestContext(t, config, bp)
_, errs := ctx.ParseFileList(".", []string{"Android.bp"})
failIfErrored(t, errs)
android.FailIfErrored(t, errs)
_, errs = ctx.PrepareBuildActions(config)
failIfErrored(t, errs)
android.FailIfErrored(t, errs)
return ctx
}
@@ -178,13 +177,13 @@ func testCcError(t *testing.T, pattern string, bp string) {
_, errs := ctx.ParseFileList(".", []string{"Android.bp"})
if len(errs) > 0 {
failIfNoMatchingErrors(t, pattern, errs)
android.FailIfNoMatchingErrors(t, pattern, errs)
return
}
_, errs = ctx.PrepareBuildActions(config)
if len(errs) > 0 {
failIfNoMatchingErrors(t, pattern, errs)
android.FailIfNoMatchingErrors(t, pattern, errs)
return
}
@@ -1064,38 +1063,6 @@ func TestLinkReordering(t *testing.T) {
}
}
func failIfErrored(t *testing.T, errs []error) {
if len(errs) > 0 {
for _, err := range errs {
t.Error(err)
}
t.FailNow()
}
}
func failIfNoMatchingErrors(t *testing.T, pattern string, errs []error) {
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)
}
}
}
func getOutputPaths(ctx *android.TestContext, variant string, moduleNames []string) (paths android.Paths) {
for _, moduleName := range moduleNames {
module := ctx.ModuleForTests(moduleName, variant).Module().(*Module)

View File

@@ -135,9 +135,9 @@ func TestDataTests(t *testing.T) {
ctx.Register()
_, errs := ctx.ParseBlueprintsFiles("Blueprints")
fail(t, errs)
android.FailIfErrored(t, errs)
_, errs = ctx.PrepareBuildActions(config)
fail(t, errs)
android.FailIfErrored(t, errs)
foo := ctx.ModuleForTests("foo", "")
@@ -186,12 +186,3 @@ func (test *testDataTest) DepsMutator(ctx android.BottomUpMutatorContext) {
func (test *testDataTest) GenerateAndroidBuildActions(ctx android.ModuleContext) {
test.data = ctx.ExpandSources(test.Properties.Data, nil)
}
func fail(t *testing.T, errs []error) {
if len(errs) > 0 {
for _, err := range errs {
t.Error(err)
}
t.FailNow()
}
}