Ignore environment variables in tests
The next change will cause java tests to fail if RUN_ERROR_PRONE=true
is set. Make tests more hermetic by faking an empty environment.
Test: soong tests
Change-Id: I01057cb0c42ec08ebed8aea87505dd01e9981915
diff --git a/android/config.go b/android/config.go
index 32a4783..4f35114 100644
--- a/android/config.go
+++ b/android/config.go
@@ -84,7 +84,8 @@
inMake bool
- captureBuild bool // true for tests, saves build parameters for each module
+ captureBuild bool // true for tests, saves build parameters for each module
+ ignoreEnvironment bool // true for tests, returns empty from all Getenv calls
OncePer
}
@@ -173,8 +174,9 @@
DeviceName: stringPtr("test_device"),
},
- buildDir: buildDir,
- captureBuild: true,
+ buildDir: buildDir,
+ captureBuild: true,
+ ignoreEnvironment: true,
}
config.deviceConfig = &deviceConfig{
config: config,
@@ -314,7 +316,9 @@
if c.envFrozen {
panic("Cannot access new environment variables after envdeps are frozen")
}
- val, _ = originalEnv[key]
+ if !c.ignoreEnvironment {
+ val, _ = originalEnv[key]
+ }
c.envDeps[key] = val
}
return val