Merge "Convert android/module_test.go to test fixtures" am: e9ae3616a2
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1640335 Change-Id: Ib548ea2b18ae6b78ba6a2a1423b9ba1656d7bf3f
This commit is contained in:
@@ -163,6 +163,10 @@ func depsModuleFactory() Module {
|
|||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var prepareForModuleTests = FixtureRegisterWithContext(func(ctx RegistrationContext) {
|
||||||
|
ctx.RegisterModuleType("deps", depsModuleFactory)
|
||||||
|
})
|
||||||
|
|
||||||
func TestErrorDependsOnDisabledModule(t *testing.T) {
|
func TestErrorDependsOnDisabledModule(t *testing.T) {
|
||||||
bp := `
|
bp := `
|
||||||
deps {
|
deps {
|
||||||
@@ -175,20 +179,15 @@ func TestErrorDependsOnDisabledModule(t *testing.T) {
|
|||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
config := TestConfig(buildDir, nil, bp, nil)
|
emptyTestFixtureFactory.
|
||||||
|
ExtendWithErrorHandler(FixtureExpectsAtLeastOneErrorMatchingPattern(`module "foo": depends on disabled module "bar"`)).
|
||||||
ctx := NewTestContext(config)
|
RunTest(t,
|
||||||
ctx.RegisterModuleType("deps", depsModuleFactory)
|
prepareForModuleTests,
|
||||||
ctx.Register()
|
FixtureWithRootAndroidBp(bp))
|
||||||
|
|
||||||
_, errs := ctx.ParseFileList(".", []string{"Android.bp"})
|
|
||||||
FailIfErrored(t, errs)
|
|
||||||
_, errs = ctx.PrepareBuildActions(config)
|
|
||||||
FailIfNoMatchingErrors(t, `module "foo": depends on disabled module "bar"`, errs)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestValidateCorrectBuildParams(t *testing.T) {
|
func TestValidateCorrectBuildParams(t *testing.T) {
|
||||||
config := TestConfig(buildDir, nil, "", nil)
|
config := TestConfig(t.TempDir(), nil, "", nil)
|
||||||
pathContext := PathContextForTesting(config)
|
pathContext := PathContextForTesting(config)
|
||||||
bparams := convertBuildParams(BuildParams{
|
bparams := convertBuildParams(BuildParams{
|
||||||
// Test with Output
|
// Test with Output
|
||||||
@@ -214,7 +213,7 @@ func TestValidateCorrectBuildParams(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestValidateIncorrectBuildParams(t *testing.T) {
|
func TestValidateIncorrectBuildParams(t *testing.T) {
|
||||||
config := TestConfig(buildDir, nil, "", nil)
|
config := TestConfig(t.TempDir(), nil, "", nil)
|
||||||
pathContext := PathContextForTesting(config)
|
pathContext := PathContextForTesting(config)
|
||||||
params := BuildParams{
|
params := BuildParams{
|
||||||
Output: PathForOutput(pathContext, "regular_output"),
|
Output: PathForOutput(pathContext, "regular_output"),
|
||||||
@@ -257,16 +256,6 @@ func TestDistErrorChecking(t *testing.T) {
|
|||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
config := TestConfig(buildDir, nil, bp, nil)
|
|
||||||
|
|
||||||
ctx := NewTestContext(config)
|
|
||||||
ctx.RegisterModuleType("deps", depsModuleFactory)
|
|
||||||
ctx.Register()
|
|
||||||
|
|
||||||
_, errs := ctx.ParseFileList(".", []string{"Android.bp"})
|
|
||||||
FailIfErrored(t, errs)
|
|
||||||
_, errs = ctx.PrepareBuildActions(config)
|
|
||||||
|
|
||||||
expectedErrs := []string{
|
expectedErrs := []string{
|
||||||
"\\QAndroid.bp:5:13: module \"foo\": dist.dest: Path is outside directory: ../invalid-dest\\E",
|
"\\QAndroid.bp:5:13: module \"foo\": dist.dest: Path is outside directory: ../invalid-dest\\E",
|
||||||
"\\QAndroid.bp:6:12: module \"foo\": dist.dir: Path is outside directory: ../invalid-dir\\E",
|
"\\QAndroid.bp:6:12: module \"foo\": dist.dir: Path is outside directory: ../invalid-dir\\E",
|
||||||
@@ -278,5 +267,10 @@ func TestDistErrorChecking(t *testing.T) {
|
|||||||
"\\QAndroid.bp:17:14: module \"foo\": dists[1].dir: Path is outside directory: ../invalid-dir1\\E",
|
"\\QAndroid.bp:17:14: module \"foo\": dists[1].dir: Path is outside directory: ../invalid-dir1\\E",
|
||||||
"\\QAndroid.bp:18:17: module \"foo\": dists[1].suffix: Suffix may not contain a '/' character.\\E",
|
"\\QAndroid.bp:18:17: module \"foo\": dists[1].suffix: Suffix may not contain a '/' character.\\E",
|
||||||
}
|
}
|
||||||
CheckErrorsAgainstExpectations(t, errs, expectedErrs)
|
|
||||||
|
emptyTestFixtureFactory.
|
||||||
|
ExtendWithErrorHandler(FixtureExpectsAllErrorsToMatchAPattern(expectedErrs)).
|
||||||
|
RunTest(t,
|
||||||
|
prepareForModuleTests,
|
||||||
|
FixtureWithRootAndroidBp(bp))
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user