From 7b0975d42f394cad332be77cc644945226a53467 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Mon, 15 Apr 2024 15:10:14 -0700 Subject: [PATCH] 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 --- bpfix/bpfix/bpfix_test.go | 7 +++++++ partner/androidmk/androidmk_test.go | 3 +++ 2 files changed, 10 insertions(+) diff --git a/bpfix/bpfix/bpfix_test.go b/bpfix/bpfix/bpfix_test.go index 672e852d4..b5b49b1ab 100644 --- a/bpfix/bpfix/bpfix_test.go +++ b/bpfix/bpfix/bpfix_test.go @@ -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()) +} diff --git a/partner/androidmk/androidmk_test.go b/partner/androidmk/androidmk_test.go index 6bae836d9..3ace7502d 100644 --- a/partner/androidmk/androidmk_test.go +++ b/partner/androidmk/androidmk_test.go @@ -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 {