Merge "Improve TestGetDistForGoals debuggability"
This commit is contained in:
commit
d35d92a7b5
|
@ -104,10 +104,12 @@ func TestAndroidMkSingleton_PassesUpdatedAndroidMkDataToCustomCallback(t *testin
|
||||||
|
|
||||||
func TestGetDistForGoals(t *testing.T) {
|
func TestGetDistForGoals(t *testing.T) {
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
|
name string
|
||||||
bp string
|
bp string
|
||||||
expectedAndroidMkLines []string
|
expectedAndroidMkLines []string
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
|
name: "dist-without-tag",
|
||||||
bp: `
|
bp: `
|
||||||
custom {
|
custom {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
|
@ -122,6 +124,7 @@ func TestGetDistForGoals(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
name: "dist-with-tag",
|
||||||
bp: `
|
bp: `
|
||||||
custom {
|
custom {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
|
@ -137,6 +140,7 @@ func TestGetDistForGoals(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
name: "dists-with-tag",
|
||||||
bp: `
|
bp: `
|
||||||
custom {
|
custom {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
|
@ -154,6 +158,7 @@ func TestGetDistForGoals(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
name: "multiple-dists-with-and-without-tag",
|
||||||
bp: `
|
bp: `
|
||||||
custom {
|
custom {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
|
@ -175,6 +180,7 @@ func TestGetDistForGoals(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
name: "dist-plus-dists-without-tags",
|
||||||
bp: `
|
bp: `
|
||||||
custom {
|
custom {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
|
@ -196,6 +202,7 @@ func TestGetDistForGoals(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
name: "dist-plus-dists-with-tags",
|
||||||
bp: `
|
bp: `
|
||||||
custom {
|
custom {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
|
@ -249,43 +256,45 @@ func TestGetDistForGoals(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, testCase := range testCases {
|
for _, testCase := range testCases {
|
||||||
config := TestConfig(buildDir, nil, testCase.bp, nil)
|
t.Run(testCase.name, func(t *testing.T) {
|
||||||
config.katiEnabled = true // Enable androidmk Singleton
|
config := TestConfig(buildDir, nil, testCase.bp, nil)
|
||||||
|
config.katiEnabled = true // Enable androidmk Singleton
|
||||||
|
|
||||||
ctx := NewTestContext(config)
|
ctx := NewTestContext(config)
|
||||||
ctx.RegisterSingletonType("androidmk", AndroidMkSingleton)
|
ctx.RegisterSingletonType("androidmk", AndroidMkSingleton)
|
||||||
ctx.RegisterModuleType("custom", customModuleFactory)
|
ctx.RegisterModuleType("custom", customModuleFactory)
|
||||||
ctx.Register()
|
ctx.Register()
|
||||||
|
|
||||||
_, errs := ctx.ParseFileList(".", []string{"Android.bp"})
|
_, errs := ctx.ParseFileList(".", []string{"Android.bp"})
|
||||||
FailIfErrored(t, errs)
|
FailIfErrored(t, errs)
|
||||||
_, errs = ctx.PrepareBuildActions(config)
|
_, errs = ctx.PrepareBuildActions(config)
|
||||||
FailIfErrored(t, errs)
|
FailIfErrored(t, errs)
|
||||||
|
|
||||||
module := ctx.ModuleForTests("foo", "").Module().(*customModule)
|
module := ctx.ModuleForTests("foo", "").Module().(*customModule)
|
||||||
entries := AndroidMkEntriesForTest(t, config, "", module)
|
entries := AndroidMkEntriesForTest(t, config, "", module)
|
||||||
if len(entries) != 1 {
|
if len(entries) != 1 {
|
||||||
t.Errorf("Expected a single AndroidMk entry, got %d", len(entries))
|
t.Errorf("Expected a single AndroidMk entry, got %d", len(entries))
|
||||||
}
|
}
|
||||||
androidMkLines := entries[0].GetDistForGoals(module)
|
androidMkLines := entries[0].GetDistForGoals(module)
|
||||||
|
|
||||||
if len(androidMkLines) != len(testCase.expectedAndroidMkLines) {
|
if len(androidMkLines) != len(testCase.expectedAndroidMkLines) {
|
||||||
t.Errorf(
|
|
||||||
"Expected %d AndroidMk lines, got %d:\n%v",
|
|
||||||
len(testCase.expectedAndroidMkLines),
|
|
||||||
len(androidMkLines),
|
|
||||||
androidMkLines,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
for idx, line := range androidMkLines {
|
|
||||||
expectedLine := testCase.expectedAndroidMkLines[idx]
|
|
||||||
if line != expectedLine {
|
|
||||||
t.Errorf(
|
t.Errorf(
|
||||||
"Expected AndroidMk line to be '%s', got '%s'",
|
"Expected %d AndroidMk lines, got %d:\n%v",
|
||||||
line,
|
len(testCase.expectedAndroidMkLines),
|
||||||
expectedLine,
|
len(androidMkLines),
|
||||||
|
androidMkLines,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
for idx, line := range androidMkLines {
|
||||||
|
expectedLine := testCase.expectedAndroidMkLines[idx]
|
||||||
|
if line != expectedLine {
|
||||||
|
t.Errorf(
|
||||||
|
"Expected AndroidMk line to be '%s', got '%s'",
|
||||||
|
expectedLine,
|
||||||
|
line,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue