Merge "Autodetect files named Android.bp in tests"
This commit is contained in:
commit
b06ad36c1f
|
@ -16,6 +16,7 @@ package android
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/google/blueprint"
|
"github.com/google/blueprint"
|
||||||
|
@ -78,6 +79,25 @@ func (ctx *TestContext) ModuleForTests(name, variant string) TestingModule {
|
||||||
return TestingModule{module}
|
return TestingModule{module}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MockFileSystem causes the Context to replace all reads with accesses to the provided map of
|
||||||
|
// filenames to contents stored as a byte slice.
|
||||||
|
func (ctx *TestContext) MockFileSystem(files map[string][]byte) {
|
||||||
|
// no module list file specified; find every file named Blueprints or Android.bp
|
||||||
|
pathsToParse := []string{}
|
||||||
|
for candidate := range files {
|
||||||
|
base := filepath.Base(candidate)
|
||||||
|
if base == "Blueprints" || base == "Android.bp" {
|
||||||
|
pathsToParse = append(pathsToParse, candidate)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(pathsToParse) < 1 {
|
||||||
|
panic(fmt.Sprintf("No Blueprint or Android.bp files found in mock filesystem: %v\n", files))
|
||||||
|
}
|
||||||
|
files[blueprint.MockModuleListFile] = []byte(strings.Join(pathsToParse, "\n"))
|
||||||
|
|
||||||
|
ctx.Context.MockFileSystem(files)
|
||||||
|
}
|
||||||
|
|
||||||
type TestingModule struct {
|
type TestingModule struct {
|
||||||
module Module
|
module Module
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue