Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 36474d32 authored by Paul Duffin's avatar Paul Duffin
Browse files

Stop sdk package depending on testing.T being embedded in TestResult

This change is in preparation for removing testing.T from TestResult.

Bug: 181070625
Test: m nothing
Change-Id: I67535aff0d894e6e3d8456b75540f340af853355
parent e84b1338
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@ func TestSnapshotWithBootImage(t *testing.T) {
		}
	`)

	CheckSnapshot(result, "mysdk", "",
	CheckSnapshot(t, result, "mysdk", "",
		checkUnversionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.

@@ -58,6 +58,5 @@ sdk_snapshot {
    boot_images: ["mysdk_mybootimage@current"],
}
`),
		checkAllCopyRules(""),
	)
		checkAllCopyRules(""))
}
+22 −32
Original line number Diff line number Diff line
@@ -54,26 +54,25 @@ func propertyStructFixture() interface{} {
	return str
}

func checkPropertySetFixture(h android.TestHelper, val interface{}, hasTags bool) {
func checkPropertySetFixture(t *testing.T, val interface{}, hasTags bool) {
	set := val.(*bpPropertySet)
	h.AssertDeepEquals("wrong x value", "taxi", set.getValue("x"))
	h.AssertDeepEquals("wrong y value", 1729, set.getValue("y"))
	android.AssertDeepEquals(t, "wrong x value", "taxi", set.getValue("x"))
	android.AssertDeepEquals(t, "wrong y value", 1729, set.getValue("y"))

	subset := set.getValue("sub").(*bpPropertySet)
	h.AssertDeepEquals("wrong sub.x value", "taxi", subset.getValue("x"))
	h.AssertDeepEquals("wrong sub.y value", 1729, subset.getValue("y"))
	android.AssertDeepEquals(t, "wrong sub.x value", "taxi", subset.getValue("x"))
	android.AssertDeepEquals(t, "wrong sub.y value", 1729, subset.getValue("y"))

	if hasTags {
		h.AssertDeepEquals("wrong y tag", "tag_y", set.getTag("y"))
		h.AssertDeepEquals("wrong sub.x tag", "tag_x", subset.getTag("x"))
		android.AssertDeepEquals(t, "wrong y tag", "tag_y", set.getTag("y"))
		android.AssertDeepEquals(t, "wrong sub.x tag", "tag_x", subset.getTag("x"))
	} else {
		h.AssertDeepEquals("wrong y tag", nil, set.getTag("y"))
		h.AssertDeepEquals("wrong sub.x tag", nil, subset.getTag("x"))
		android.AssertDeepEquals(t, "wrong y tag", nil, set.getTag("y"))
		android.AssertDeepEquals(t, "wrong sub.x tag", nil, subset.getTag("x"))
	}
}

func TestAddPropertySimple(t *testing.T) {
	h := android.TestHelper{t}
	set := newPropertySet()
	for name, val := range map[string]interface{}{
		"x":   "taxi",
@@ -83,16 +82,15 @@ func TestAddPropertySimple(t *testing.T) {
		"arr": []string{"a", "b", "c"},
	} {
		set.AddProperty(name, val)
		h.AssertDeepEquals("wrong value", val, set.getValue(name))
		android.AssertDeepEquals(t, "wrong value", val, set.getValue(name))
	}
	h.AssertPanic("adding x again should panic",
	android.AssertPanic(t, "adding x again should panic",
		func() { set.AddProperty("x", "taxi") })
	h.AssertPanic("adding arr again should panic",
	android.AssertPanic(t, "adding arr again should panic",
		func() { set.AddProperty("arr", []string{"d"}) })
}

func TestAddPropertySubset(t *testing.T) {
	h := android.TestHelper{t}
	getFixtureMap := map[string]func() interface{}{
		"property set":    propertySetFixture,
		"property struct": propertyStructFixture,
@@ -103,8 +101,8 @@ func TestAddPropertySubset(t *testing.T) {
			t.Run(name, func(t *testing.T) {
				set := propertySetFixture().(*bpPropertySet)
				set.AddProperty("new", getFixture())
				checkPropertySetFixture(h, set, true)
				checkPropertySetFixture(h, set.getValue("new"), name == "property set")
				checkPropertySetFixture(t, set, true)
				checkPropertySetFixture(t, set.getValue("new"), name == "property set")
			})
		}
	})
@@ -118,40 +116,38 @@ func TestAddPropertySubset(t *testing.T) {
				subset.AddPropertySet("sub")
				set.AddProperty("sub", getFixture())
				merged := set.getValue("sub").(*bpPropertySet)
				h.AssertDeepEquals("wrong flag value", false, merged.getValue("flag"))
				checkPropertySetFixture(h, merged, name == "property set")
				android.AssertDeepEquals(t, "wrong flag value", false, merged.getValue("flag"))
				checkPropertySetFixture(t, merged, name == "property set")
			})
		}
	})

	t.Run("add conflicting subset", func(t *testing.T) {
		set := propertySetFixture().(*bpPropertySet)
		h.AssertPanic("adding x again should panic",
		android.AssertPanic(t, "adding x again should panic",
			func() { set.AddProperty("x", propertySetFixture()) })
	})

	t.Run("add non-pointer struct", func(t *testing.T) {
		set := propertySetFixture().(*bpPropertySet)
		str := propertyStructFixture().(*propertyStruct)
		h.AssertPanic("adding a non-pointer struct should panic",
		android.AssertPanic(t, "adding a non-pointer struct should panic",
			func() { set.AddProperty("new", *str) })
	})
}

func TestAddPropertySetNew(t *testing.T) {
	h := android.TestHelper{t}
	set := newPropertySet()
	subset := set.AddPropertySet("sub")
	subset.AddProperty("new", "d^^b")
	h.AssertDeepEquals("wrong sub.new value", "d^^b", set.getValue("sub").(*bpPropertySet).getValue("new"))
	android.AssertDeepEquals(t, "wrong sub.new value", "d^^b", set.getValue("sub").(*bpPropertySet).getValue("new"))
}

func TestAddPropertySetExisting(t *testing.T) {
	h := android.TestHelper{t}
	set := propertySetFixture().(*bpPropertySet)
	subset := set.AddPropertySet("sub")
	subset.AddProperty("new", "d^^b")
	h.AssertDeepEquals("wrong sub.new value", "d^^b", set.getValue("sub").(*bpPropertySet).getValue("new"))
	android.AssertDeepEquals(t, "wrong sub.new value", "d^^b", set.getValue("sub").(*bpPropertySet).getValue("new"))
}

type removeFredTransformation struct {
@@ -180,9 +176,6 @@ func (t removeFredTransformation) transformPropertySetAfterContents(name string,
}

func TestTransformRemoveProperty(t *testing.T) {

	helper := android.TestHelper{t}

	set := newPropertySet()
	set.AddProperty("name", "name")
	set.AddProperty("fred", "12")
@@ -191,13 +184,10 @@ func TestTransformRemoveProperty(t *testing.T) {

	contents := &generatedContents{}
	outputPropertySet(contents, set)
	helper.AssertTrimmedStringEquals("removing property failed", "name: \"name\",\n", contents.content.String())
	android.AssertTrimmedStringEquals(t, "removing property failed", "name: \"name\",\n", contents.content.String())
}

func TestTransformRemovePropertySet(t *testing.T) {

	helper := android.TestHelper{t}

	set := newPropertySet()
	set.AddProperty("name", "name")
	set.AddPropertySet("fred")
@@ -206,5 +196,5 @@ func TestTransformRemovePropertySet(t *testing.T) {

	contents := &generatedContents{}
	outputPropertySet(contents, set)
	helper.AssertTrimmedStringEquals("removing property set failed", "name: \"name\",\n", contents.content.String())
	android.AssertTrimmedStringEquals(t, "removing property set failed", "name: \"name\",\n", contents.content.String())
}
+26 −27
Original line number Diff line number Diff line
@@ -101,7 +101,7 @@ func TestSdkCompileMultilibOverride(t *testing.T) {
		}
	`)

	CheckSnapshot(result, "mysdk", "",
	CheckSnapshot(t, result, "mysdk", "",
		checkUnversionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.

@@ -353,7 +353,7 @@ func TestSnapshotWithObject(t *testing.T) {
		}
	`)

	CheckSnapshot(result, "mysdk", "",
	CheckSnapshot(t, result, "mysdk", "",
		checkUnversionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.

@@ -440,7 +440,7 @@ func TestSnapshotWithCcDuplicateHeaders(t *testing.T) {
		}
	`)

	CheckSnapshot(result, "mysdk", "",
	CheckSnapshot(t, result, "mysdk", "",
		checkAllCopyRules(`
myinclude/Test.h -> include/myinclude/Test.h
.intermediates/mynativelib1/android_arm64_armv8-a_shared/mynativelib1.so -> arm64/lib/mynativelib1.so
@@ -486,7 +486,7 @@ func TestSnapshotWithCcExportGeneratedHeaders(t *testing.T) {
		}
	`)

	CheckSnapshot(result, "mysdk", "",
	CheckSnapshot(t, result, "mysdk", "",
		checkUnversionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.

@@ -556,7 +556,7 @@ func TestSnapshotWithCcSharedLibraryCommonProperties(t *testing.T) {
		}
	`)

	CheckSnapshot(result, "mysdk", "",
	CheckSnapshot(t, result, "mysdk", "",
		checkUnversionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.

@@ -615,7 +615,7 @@ func TestSnapshotWithCcBinary(t *testing.T) {
		}
	`)

	CheckSnapshot(result, "mymodule_exports", "",
	CheckSnapshot(t, result, "mymodule_exports", "",
		checkUnversionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.

@@ -700,7 +700,7 @@ func TestMultipleHostOsTypesSnapshotWithCcBinary(t *testing.T) {
		}
	`)

	CheckSnapshot(result, "myexports", "",
	CheckSnapshot(t, result, "myexports", "",
		checkUnversionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.

@@ -859,7 +859,7 @@ func TestSnapshotWithSingleHostOsType(t *testing.T) {
		}
	`)

	CheckSnapshot(result, "myexports", "",
	CheckSnapshot(t, result, "myexports", "",
		checkUnversionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.

@@ -997,7 +997,7 @@ func TestSnapshotWithCcStaticNocrtBinary(t *testing.T) {
		}
	`)

	CheckSnapshot(result, "mymodule_exports", "",
	CheckSnapshot(t, result, "mymodule_exports", "",
		checkUnversionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.

@@ -1105,7 +1105,7 @@ func TestSnapshotWithCcSharedLibrary(t *testing.T) {
		}
	`)

	CheckSnapshot(result, "mysdk", "",
	CheckSnapshot(t, result, "mysdk", "",
		checkUnversionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.

@@ -1206,7 +1206,7 @@ func TestSnapshotWithCcSharedLibrarySharedLibs(t *testing.T) {
		}
	`)

	CheckSnapshot(result, "mysdk", "",
	CheckSnapshot(t, result, "mysdk", "",
		checkUnversionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.

@@ -1303,7 +1303,7 @@ func TestHostSnapshotWithCcSharedLibrary(t *testing.T) {
		}
	`)

	CheckSnapshot(result, "mysdk", "",
	CheckSnapshot(t, result, "mysdk", "",
		checkUnversionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.

@@ -1430,7 +1430,7 @@ func TestMultipleHostOsTypesSnapshotWithCcSharedLibrary(t *testing.T) {
		}
	`)

	CheckSnapshot(result, "mysdk", "",
	CheckSnapshot(t, result, "mysdk", "",
		checkUnversionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.

@@ -1558,7 +1558,7 @@ func TestSnapshotWithCcStaticLibrary(t *testing.T) {
		}
	`)

	CheckSnapshot(result, "myexports", "",
	CheckSnapshot(t, result, "myexports", "",
		checkUnversionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.

@@ -1621,7 +1621,7 @@ func TestHostSnapshotWithCcStaticLibrary(t *testing.T) {
		}
	`)

	CheckSnapshot(result, "myexports", "",
	CheckSnapshot(t, result, "myexports", "",
		checkUnversionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.

@@ -1735,7 +1735,7 @@ func TestSnapshotWithCcLibrary(t *testing.T) {
		}
	`)

	CheckSnapshot(result, "myexports", "",
	CheckSnapshot(t, result, "myexports", "",
		checkUnversionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.

@@ -1849,7 +1849,7 @@ func TestHostSnapshotWithMultiLib64(t *testing.T) {
		}
	`)

	CheckSnapshot(result, "myexports", "",
	CheckSnapshot(t, result, "myexports", "",
		checkUnversionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.

@@ -1946,7 +1946,7 @@ func TestSnapshotWithCcHeadersLibrary(t *testing.T) {
		}
	`)

	CheckSnapshot(result, "mysdk", "",
	CheckSnapshot(t, result, "mysdk", "",
		checkUnversionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.

@@ -1984,7 +1984,7 @@ func TestHostSnapshotWithCcHeadersLibrary(t *testing.T) {
		}
	`)

	CheckSnapshot(result, "mysdk", "",
	CheckSnapshot(t, result, "mysdk", "",
		checkUnversionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.

@@ -2086,7 +2086,7 @@ func TestDeviceAndHostSnapshotWithCcHeadersLibrary(t *testing.T) {
		}
	`)

	CheckSnapshot(result, "mysdk", "",
	CheckSnapshot(t, result, "mysdk", "",
		checkUnversionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.

@@ -2118,7 +2118,6 @@ cc_prebuilt_library_headers {
    },
}
`),
		// Verifi
		checkVersionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.

@@ -2199,7 +2198,7 @@ func TestSystemSharedLibPropagation(t *testing.T) {
		}
	`)

	CheckSnapshot(result, "mysdk", "",
	CheckSnapshot(t, result, "mysdk", "",
		checkUnversionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.

@@ -2272,7 +2271,7 @@ cc_prebuilt_library_shared {
		}
	`)

	CheckSnapshot(result, "mysdk", "",
	CheckSnapshot(t, result, "mysdk", "",
		checkUnversionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.

@@ -2383,7 +2382,7 @@ func TestStubsLibrary(t *testing.T) {
		}
	`)

	CheckSnapshot(result, "mysdk", "",
	CheckSnapshot(t, result, "mysdk", "",
		checkUnversionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.

@@ -2436,7 +2435,7 @@ func TestDeviceAndHostSnapshotWithStubsLibrary(t *testing.T) {
		}
	`)

	CheckSnapshot(result, "mysdk", "",
	CheckSnapshot(t, result, "mysdk", "",
		checkUnversionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.

@@ -2549,7 +2548,7 @@ func TestUniqueHostSoname(t *testing.T) {
		}
	`)

	CheckSnapshot(result, "mysdk", "",
	CheckSnapshot(t, result, "mysdk", "",
		checkUnversionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.

@@ -2664,7 +2663,7 @@ func TestNoSanitizerMembers(t *testing.T) {
		}
	`)

	CheckSnapshot(result, "mysdk", "",
	CheckSnapshot(t, result, "mysdk", "",
		checkUnversionedAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.

+1 −1
Original line number Diff line number Diff line
@@ -42,7 +42,7 @@ func TestModuleExportsSnapshot(t *testing.T) {
			"package/Android.bp": []byte(packageBp),
		})

	CheckSnapshot(result, "myexports", "package",
	CheckSnapshot(t, result, "myexports", "package",
		checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.

+20 −20
Original line number Diff line number Diff line
@@ -128,7 +128,7 @@ func TestSdkDependsOnSourceEvenWhenPrebuiltPreferred(t *testing.T) {
	// Make sure that the mysdk module depends on "sdkmember" and not "prebuilt_sdkmember".
	java.CheckModuleDependencies(t, result.TestContext, "mysdk", "android_common", []string{"sdkmember"})

	CheckSnapshot(result, "mysdk", "",
	CheckSnapshot(t, result, "mysdk", "",
		checkAndroidBpContents(`// This is auto-generated. DO NOT EDIT.

java_import {
@@ -256,7 +256,7 @@ func TestSnapshotWithJavaHeaderLibrary(t *testing.T) {
		}
	`)

	CheckSnapshot(result, "mysdk", "",
	CheckSnapshot(t, result, "mysdk", "",
		checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.

@@ -313,7 +313,7 @@ func TestHostSnapshotWithJavaHeaderLibrary(t *testing.T) {
		}
	`)

	CheckSnapshot(result, "mysdk", "",
	CheckSnapshot(t, result, "mysdk", "",
		checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.

@@ -370,7 +370,7 @@ func TestDeviceAndHostSnapshotWithJavaHeaderLibrary(t *testing.T) {
		}
	`)

	CheckSnapshot(result, "mysdk", "",
	CheckSnapshot(t, result, "mysdk", "",
		checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.

@@ -441,7 +441,7 @@ func TestSnapshotWithJavaImplLibrary(t *testing.T) {
		}
	`)

	CheckSnapshot(result, "myexports", "",
	CheckSnapshot(t, result, "myexports", "",
		checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.

@@ -497,7 +497,7 @@ func TestSnapshotWithJavaBootLibrary(t *testing.T) {
		}
	`)

	CheckSnapshot(result, "myexports", "",
	CheckSnapshot(t, result, "myexports", "",
		checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.

@@ -552,7 +552,7 @@ func TestHostSnapshotWithJavaImplLibrary(t *testing.T) {
		}
	`)

	CheckSnapshot(result, "myexports", "",
	CheckSnapshot(t, result, "myexports", "",
		checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.

@@ -608,7 +608,7 @@ func TestSnapshotWithJavaTest(t *testing.T) {
		}
	`)

	CheckSnapshot(result, "myexports", "",
	CheckSnapshot(t, result, "myexports", "",
		checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.

@@ -663,7 +663,7 @@ func TestHostSnapshotWithJavaTest(t *testing.T) {
		}
	`)

	CheckSnapshot(result, "myexports", "",
	CheckSnapshot(t, result, "myexports", "",
		checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.

@@ -732,7 +732,7 @@ func TestSnapshotWithJavaSystemModules(t *testing.T) {
		}
	`)

	CheckSnapshot(result, "mysdk", "",
	CheckSnapshot(t, result, "mysdk", "",
		checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.

@@ -828,7 +828,7 @@ func TestHostSnapshotWithJavaSystemModules(t *testing.T) {
		}
	`)

	CheckSnapshot(result, "mysdk", "",
	CheckSnapshot(t, result, "mysdk", "",
		checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.

@@ -919,7 +919,7 @@ func TestDeviceAndHostSnapshotWithOsSpecificMembers(t *testing.T) {
		}
	`)

	CheckSnapshot(result, "myexports", "",
	CheckSnapshot(t, result, "myexports", "",
		checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.

@@ -1033,7 +1033,7 @@ func TestSnapshotWithJavaSdkLibrary(t *testing.T) {
		}
	`)

	CheckSnapshot(result, "mysdk", "",
	CheckSnapshot(t, result, "mysdk", "",
		checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.

@@ -1134,7 +1134,7 @@ func TestSnapshotWithJavaSdkLibrary_SdkVersion_None(t *testing.T) {
		}
	`)

	CheckSnapshot(result, "mysdk", "",
	CheckSnapshot(t, result, "mysdk", "",
		checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.

@@ -1203,7 +1203,7 @@ func TestSnapshotWithJavaSdkLibrary_SdkVersion_ForScope(t *testing.T) {
		}
	`)

	CheckSnapshot(result, "mysdk", "",
	CheckSnapshot(t, result, "mysdk", "",
		checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.

@@ -1275,7 +1275,7 @@ func TestSnapshotWithJavaSdkLibrary_ApiScopes(t *testing.T) {
		}
	`)

	CheckSnapshot(result, "mysdk", "",
	CheckSnapshot(t, result, "mysdk", "",
		checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.

@@ -1368,7 +1368,7 @@ func TestSnapshotWithJavaSdkLibrary_ModuleLib(t *testing.T) {
		}
	`)

	CheckSnapshot(result, "mysdk", "",
	CheckSnapshot(t, result, "mysdk", "",
		checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.

@@ -1476,7 +1476,7 @@ func TestSnapshotWithJavaSdkLibrary_SystemServer(t *testing.T) {
		}
	`)

	CheckSnapshot(result, "mysdk", "",
	CheckSnapshot(t, result, "mysdk", "",
		checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.

@@ -1564,7 +1564,7 @@ func TestSnapshotWithJavaSdkLibrary_NamingScheme(t *testing.T) {
		}
	`)

	CheckSnapshot(result, "mysdk", "",
	CheckSnapshot(t, result, "mysdk", "",
		checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.

@@ -1640,7 +1640,7 @@ func TestSnapshotWithJavaSdkLibrary_DoctagFiles(t *testing.T) {
		}
	`)

	CheckSnapshot(result, "mysdk", "",
	CheckSnapshot(t, result, "mysdk", "",
		checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.

Loading