Fix tests with cc_binary_host on mac
cc_binary_host on mac uses ctx.Config().HostSystemTool(), which needs
PATH in the test environment. Copy it from the original environment.
Fixes: 129763458
Test: proto_test.go
Change-Id: I41c1acdceee7c35036148256adafb471871034df
diff --git a/android/config.go b/android/config.go
index 3af448d..26f9ca8 100644
--- a/android/config.go
+++ b/android/config.go
@@ -198,6 +198,14 @@
// TestConfig returns a Config object suitable for using for tests
func TestConfig(buildDir string, env map[string]string) Config {
+ envCopy := make(map[string]string)
+ for k, v := range env {
+ envCopy[k] = v
+ }
+
+ // Copy the real PATH value to the test environment, it's needed by HostSystemTool() used in x86_darwin_host.go
+ envCopy["PATH"] = originalEnv["PATH"]
+
config := &config{
productVariables: productVariables{
DeviceName: stringPtr("test_device"),
@@ -212,7 +220,7 @@
buildDir: buildDir,
captureBuild: true,
- env: env,
+ env: envCopy,
}
config.deviceConfig = &deviceConfig{
config: config,