Merge "Convert android/csuite_config_test.go to test fixtures"
This commit is contained in:
commit
28f0e9e2cb
|
@ -15,7 +15,11 @@
|
||||||
package android
|
package android
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
RegisterModuleType("csuite_config", CSuiteConfigFactory)
|
registerCSuiteBuildComponents(InitRegistrationContext)
|
||||||
|
}
|
||||||
|
|
||||||
|
func registerCSuiteBuildComponents(ctx RegistrationContext) {
|
||||||
|
ctx.RegisterModuleType("csuite_config", CSuiteConfigFactory)
|
||||||
}
|
}
|
||||||
|
|
||||||
type csuiteConfigProperties struct {
|
type csuiteConfigProperties struct {
|
||||||
|
|
|
@ -18,32 +18,21 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func testCSuiteConfig(test *testing.T, bpFileContents string) *TestContext {
|
|
||||||
config := TestArchConfig(buildDir, nil, bpFileContents, nil)
|
|
||||||
|
|
||||||
ctx := NewTestArchContext(config)
|
|
||||||
ctx.RegisterModuleType("csuite_config", CSuiteConfigFactory)
|
|
||||||
ctx.Register()
|
|
||||||
_, errs := ctx.ParseFileList(".", []string{"Android.bp"})
|
|
||||||
FailIfErrored(test, errs)
|
|
||||||
_, errs = ctx.PrepareBuildActions(config)
|
|
||||||
FailIfErrored(test, errs)
|
|
||||||
return ctx
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestCSuiteConfig(t *testing.T) {
|
func TestCSuiteConfig(t *testing.T) {
|
||||||
ctx := testCSuiteConfig(t, `
|
result := emptyTestFixtureFactory.RunTest(t,
|
||||||
csuite_config { name: "plain"}
|
PrepareForTestWithArchMutator,
|
||||||
csuite_config { name: "with_manifest", test_config: "manifest.xml" }
|
FixtureRegisterWithContext(registerCSuiteBuildComponents),
|
||||||
`)
|
FixtureWithRootAndroidBp(`
|
||||||
|
csuite_config { name: "plain"}
|
||||||
|
csuite_config { name: "with_manifest", test_config: "manifest.xml" }
|
||||||
|
`),
|
||||||
|
)
|
||||||
|
|
||||||
variants := ctx.ModuleVariantsForTests("plain")
|
variants := result.ModuleVariantsForTests("plain")
|
||||||
if len(variants) > 1 {
|
if len(variants) > 1 {
|
||||||
t.Errorf("expected 1, got %d", len(variants))
|
t.Errorf("expected 1, got %d", len(variants))
|
||||||
}
|
}
|
||||||
expectedOutputFilename := ctx.ModuleForTests(
|
outputFilename := result.ModuleForTests(
|
||||||
"plain", variants[0]).Module().(*CSuiteConfig).OutputFilePath.Base()
|
"plain", variants[0]).Module().(*CSuiteConfig).OutputFilePath.Base()
|
||||||
if expectedOutputFilename != "plain" {
|
AssertStringEquals(t, "output file name", "plain", outputFilename)
|
||||||
t.Errorf("expected plain, got %q", expectedOutputFilename)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue