Fix more tests when ANDROID_BUILD_TOP is set

The bpfix code (also used by androidmk) reads the ANDROID_BUILD_TOP
environment variable, causing the tests to fail when it is set.  Clear
it in the bpfix and partner androidmk tests the same way the main
androidmk tests do.

Test: go test ./...
Change-Id: Icc61f2c3ebdbecab34c1d18399c6846db207c6dd
This commit is contained in:
Colin Cross 2024-04-15 15:10:14 -07:00
parent 935b4db4cb
commit 7b0975d42f
2 changed files with 10 additions and 0 deletions

View file

@ -19,6 +19,7 @@ package bpfix
import (
"bytes"
"fmt"
"os"
"reflect"
"strings"
"testing"
@ -2215,3 +2216,9 @@ func TestRemoveResourceAndAssetsIfDefault(t *testing.T) {
})
}
}
func TestMain(m *testing.M) {
// Skip checking Android.mk path with cleaning "ANDROID_BUILD_TOP"
os.Setenv("ANDROID_BUILD_TOP", "")
os.Exit(m.Run())
}

View file

@ -54,6 +54,9 @@ cc_library_shared {
}
func TestEndToEnd(t *testing.T) {
// Skip checking Android.mk path with cleaning "ANDROID_BUILD_TOP"
t.Setenv("ANDROID_BUILD_TOP", "")
for i, test := range testCases {
expected, err := bpfix.Reformat(test.expected)
if err != nil {