Allow createGlobalSoongConfig() to be used from tests

Previously, the createGlobalSoongConfig() function was explicitly
prevented from being used in tests because it would fail. However, it
turns out that is no longer the case and it does now work.

That allows the following changes to be made:
* Tests no longer need to use GlobalSoongConfigForTests() to
  prepopulate the cache.
* GlobalSoongConfigForTests() is only needed in the dexpreopt
  package.

Bug: 177892522
Test: m nothing
Change-Id: Ifcbb1a44254c5d2d10c1d02ab23227488d1d1ed1
This commit is contained in:
Paul Duffin
2021-01-21 15:05:11 +00:00
parent c059c8c9a0
commit 9f04524673
4 changed files with 15 additions and 34 deletions

View File

@@ -61,13 +61,7 @@ func TestMain(m *testing.M) {
func testConfig(env map[string]string, bp string, fs map[string][]byte) android.Config {
bp += dexpreopt.BpToolModulesForTest()
config := TestConfig(buildDir, env, bp, fs)
// Set up the global Once cache used for dexpreopt.GlobalSoongConfig, so that
// it doesn't create a real one, which would fail.
_ = dexpreopt.GlobalSoongConfigForTests(config)
return config
return TestConfig(buildDir, env, bp, fs)
}
func testContext(config android.Config) *android.TestContext {