From 9c6241f768dd95663a490c5df276528b84176998 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Mon, 22 Apr 2019 15:51:26 -0700 Subject: [PATCH] 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 --- android/config.go | 10 +++++++++- cc/proto_test.go | 4 ---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/android/config.go b/android/config.go index 3af448d45..26f9ca8eb 100644 --- a/android/config.go +++ b/android/config.go @@ -198,6 +198,14 @@ func saveToConfigFile(config jsonConfigurable, filename string) error { // 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 @@ func TestConfig(buildDir string, env map[string]string) Config { buildDir: buildDir, captureBuild: true, - env: env, + env: envCopy, } config.deviceConfig = &deviceConfig{ config: config, diff --git a/cc/proto_test.go b/cc/proto_test.go index a7fcef935..4f0de7801 100644 --- a/cc/proto_test.go +++ b/cc/proto_test.go @@ -15,7 +15,6 @@ package cc import ( - "runtime" "strings" "testing" @@ -38,9 +37,6 @@ func TestProto(t *testing.T) { }) t.Run("plugin", func(t *testing.T) { - if runtime.GOOS != "linux" { - t.Skip("TODO(b/129763458): cc_binary_host tests fail on mac when trying to exec xcrun") - } ctx := testCc(t, ` cc_binary_host { name: "protoc-gen-foobar",