Add a test for AddNinjaFileDeps am: 7a2a352825
am: bec4769941
Original change: https://android-review.googlesource.com/c/platform/build/blueprint/+/1715723 Change-Id: Iadeb6705befa4dba70a714f958873e6fcd4cba46
This commit is contained in:
commit
c36186601c
1 changed files with 100 additions and 0 deletions
|
@ -531,3 +531,103 @@ test2 {
|
|||
)
|
||||
})
|
||||
}
|
||||
|
||||
type addNinjaDepsTestModule struct {
|
||||
SimpleName
|
||||
}
|
||||
|
||||
func addNinjaDepsTestModuleFactory() (Module, []interface{}) {
|
||||
module := &addNinjaDepsTestModule{}
|
||||
AddLoadHook(module, func(ctx LoadHookContext) {
|
||||
ctx.AddNinjaFileDeps("LoadHookContext")
|
||||
})
|
||||
return module, []interface{}{&module.SimpleName.Properties}
|
||||
}
|
||||
|
||||
func (m *addNinjaDepsTestModule) GenerateBuildActions(ctx ModuleContext) {
|
||||
ctx.AddNinjaFileDeps("GenerateBuildActions")
|
||||
}
|
||||
|
||||
func addNinjaDepsTestBottomUpMutator(ctx BottomUpMutatorContext) {
|
||||
ctx.AddNinjaFileDeps("BottomUpMutator")
|
||||
}
|
||||
|
||||
func addNinjaDepsTestTopDownMutator(ctx TopDownMutatorContext) {
|
||||
ctx.AddNinjaFileDeps("TopDownMutator")
|
||||
}
|
||||
|
||||
type addNinjaDepsTestPreSingleton struct{}
|
||||
|
||||
func addNinjaDepsTestPreSingletonFactory() Singleton {
|
||||
return &addNinjaDepsTestPreSingleton{}
|
||||
}
|
||||
|
||||
func (s *addNinjaDepsTestPreSingleton) GenerateBuildActions(ctx SingletonContext) {
|
||||
ctx.AddNinjaFileDeps("PreSingleton")
|
||||
}
|
||||
|
||||
type addNinjaDepsTestSingleton struct{}
|
||||
|
||||
func addNinjaDepsTestSingletonFactory() Singleton {
|
||||
return &addNinjaDepsTestSingleton{}
|
||||
}
|
||||
|
||||
func (s *addNinjaDepsTestSingleton) GenerateBuildActions(ctx SingletonContext) {
|
||||
ctx.AddNinjaFileDeps("Singleton")
|
||||
}
|
||||
|
||||
func TestAddNinjaFileDeps(t *testing.T) {
|
||||
ctx := NewContext()
|
||||
ctx.MockFileSystem(map[string][]byte{
|
||||
"Blueprints": []byte(`
|
||||
test {
|
||||
name: "test",
|
||||
}
|
||||
`),
|
||||
})
|
||||
|
||||
ctx.RegisterModuleType("test", addNinjaDepsTestModuleFactory)
|
||||
ctx.RegisterBottomUpMutator("testBottomUpMutator", addNinjaDepsTestBottomUpMutator)
|
||||
ctx.RegisterTopDownMutator("testTopDownMutator", addNinjaDepsTestTopDownMutator)
|
||||
ctx.RegisterPreSingletonType("testPreSingleton", addNinjaDepsTestPreSingletonFactory)
|
||||
ctx.RegisterSingletonType("testSingleton", addNinjaDepsTestSingletonFactory)
|
||||
parseDeps, errs := ctx.ParseBlueprintsFiles("Blueprints", nil)
|
||||
if len(errs) > 0 {
|
||||
t.Errorf("unexpected parse errors:")
|
||||
for _, err := range errs {
|
||||
t.Errorf(" %s", err)
|
||||
}
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
resolveDeps, errs := ctx.ResolveDependencies(nil)
|
||||
if len(errs) > 0 {
|
||||
t.Errorf("unexpected dep errors:")
|
||||
for _, err := range errs {
|
||||
t.Errorf(" %s", err)
|
||||
}
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
prepareDeps, errs := ctx.PrepareBuildActions(nil)
|
||||
if len(errs) > 0 {
|
||||
t.Errorf("unexpected prepare errors:")
|
||||
for _, err := range errs {
|
||||
t.Errorf(" %s", err)
|
||||
}
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
if g, w := parseDeps, []string{"Blueprints", "LoadHookContext"}; !reflect.DeepEqual(g, w) {
|
||||
t.Errorf("ParseBlueprintsFiles: wanted deps %q, got %q", w, g)
|
||||
}
|
||||
|
||||
if g, w := resolveDeps, []string{"PreSingleton", "BottomUpMutator", "TopDownMutator"}; !reflect.DeepEqual(g, w) {
|
||||
t.Errorf("ResolveDependencies: wanted deps %q, got %q", w, g)
|
||||
}
|
||||
|
||||
if g, w := prepareDeps, []string{"GenerateBuildActions", "Singleton"}; !reflect.DeepEqual(g, w) {
|
||||
t.Errorf("PrepareBuildActions: wanted deps %q, got %q", w, g)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue