diff options
author | Logan Chien <loganchien@google.com> | 2018-03-12 16:34:26 +0800 |
---|---|---|
committer | Logan Chien <loganchien@google.com> | 2018-03-16 17:45:42 +0800 |
commit | b1ed497ca81762b5f431f08e3f1bbca8fc94bfa1 (patch) | |
tree | 04975ffd38baceed2bcf4450ff6e4df9b5912d0d /cc/cc_test.go | |
parent | d44aa3b5c8afbfeb66e39668bab3ec0fac63f1e6 (diff) | |
download | build_soong-b1ed497ca81762b5f431f08e3f1bbca8fc94bfa1.tar.gz build_soong-b1ed497ca81762b5f431f08e3f1bbca8fc94bfa1.tar.bz2 build_soong-b1ed497ca81762b5f431f08e3f1bbca8fc94bfa1.zip |
Add unit tests for android/neverallow.go
Bug: 74506774
Test: lunch aosp_walleye-userdebug && make # runs unit tests
Merged-In: Ibde685d7213713be219681cb039ad58a43d9c377
Change-Id: Ibde685d7213713be219681cb039ad58a43d9c377
Diffstat (limited to 'cc/cc_test.go')
-rw-r--r-- | cc/cc_test.go | 28 |
1 files changed, 2 insertions, 26 deletions
diff --git a/cc/cc_test.go b/cc/cc_test.go index 63296056..2efee59d 100644 --- a/cc/cc_test.go +++ b/cc/cc_test.go @@ -22,7 +22,6 @@ import ( "io/ioutil" "os" "reflect" - "regexp" "sort" "strings" "testing" @@ -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,29 +1063,6 @@ func TestLinkReordering(t *testing.T) { } } -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) |