Add tests for ctx.InstallFile
Add tests that cover Soong-only installation as well as installation with InstallBypassMake. Bug: 204136549 Test: TestInstall Test: TestInstallBypassMake Change-Id: Iac22c9fdf99994e06b419623ee5fa399ef6957fb
This commit is contained in:
@@ -142,15 +142,19 @@ type SingletonMakeVarsProvider interface {
|
||||
|
||||
var singletonMakeVarsProvidersKey = NewOnceKey("singletonMakeVarsProvidersKey")
|
||||
|
||||
func getSingletonMakevarsProviders(config Config) *[]makeVarsProvider {
|
||||
return config.Once(singletonMakeVarsProvidersKey, func() interface{} {
|
||||
return &[]makeVarsProvider{}
|
||||
}).(*[]makeVarsProvider)
|
||||
}
|
||||
|
||||
// registerSingletonMakeVarsProvider adds a singleton that implements SingletonMakeVarsProvider to
|
||||
// the list of MakeVarsProviders to run.
|
||||
func registerSingletonMakeVarsProvider(config Config, singleton SingletonMakeVarsProvider) {
|
||||
// Singletons are registered on the Context and may be different between different Contexts,
|
||||
// for example when running multiple tests. Store the SingletonMakeVarsProviders in the
|
||||
// Config so they are attached to the Context.
|
||||
singletonMakeVarsProviders := config.Once(singletonMakeVarsProvidersKey, func() interface{} {
|
||||
return &[]makeVarsProvider{}
|
||||
}).(*[]makeVarsProvider)
|
||||
singletonMakeVarsProviders := getSingletonMakevarsProviders(config)
|
||||
|
||||
*singletonMakeVarsProviders = append(*singletonMakeVarsProviders,
|
||||
makeVarsProvider{pctx, singletonMakeVarsProviderAdapter(singleton)})
|
||||
@@ -175,7 +179,9 @@ func makeVarsSingletonFunc() Singleton {
|
||||
return &makeVarsSingleton{}
|
||||
}
|
||||
|
||||
type makeVarsSingleton struct{}
|
||||
type makeVarsSingleton struct {
|
||||
installsForTesting []byte
|
||||
}
|
||||
|
||||
type makeVarsProvider struct {
|
||||
pctx PackageContext
|
||||
@@ -238,7 +244,7 @@ func (s *makeVarsSingleton) GenerateBuildActions(ctx SingletonContext) {
|
||||
var katiSymlinks []katiInstall
|
||||
|
||||
providers := append([]makeVarsProvider(nil), makeVarsInitProviders...)
|
||||
providers = append(providers, *ctx.Config().Get(singletonMakeVarsProvidersKey).(*[]makeVarsProvider)...)
|
||||
providers = append(providers, *getSingletonMakevarsProviders(ctx.Config())...)
|
||||
|
||||
for _, provider := range providers {
|
||||
mctx := &makeVarsContext{
|
||||
@@ -313,6 +319,8 @@ func (s *makeVarsSingleton) GenerateBuildActions(ctx SingletonContext) {
|
||||
if err := pathtools.WriteFileIfChanged(installsFile, installsBytes, 0666); err != nil {
|
||||
ctx.Errorf(err.Error())
|
||||
}
|
||||
|
||||
s.installsForTesting = installsBytes
|
||||
}
|
||||
|
||||
func (s *makeVarsSingleton) writeVars(vars []makeVarsVariable) []byte {
|
||||
|
Reference in New Issue
Block a user