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

Commit e9a3668e authored by Aditya Choudhary's avatar Aditya Choudhary Committed by Automerger Merge Worker
Browse files

Merge "Add Singleton class to collect and validate test spec metadata." into...

Merge "Add Singleton class to collect and validate test spec metadata." into main am: 29766f4d am: eb7cc75c am: 8c16b083

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2824671



Change-Id: I961412838b7c109a5e3ca0b63b70010dfcd239c3
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 7b1f4c23 8c16b083
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -12,6 +12,7 @@ bootstrap_go_package {

    ],
    srcs: [
        "all_test_specs.go",
        "test_spec.go",
        "init.go",
    ],
+45 −0
Original line number Diff line number Diff line
package testing

import (
	"android/soong/android"
)

const ownershipDirectory = "ownership"
const fileContainingFilePaths = "all_test_spec_paths.rsp"
const allTestSpecsFile = "all_test_specs.pb"

func AllTestSpecsFactory() android.Singleton {
	return &allTestSpecsSingleton{}
}

type allTestSpecsSingleton struct {
	// Path where the collected metadata is stored after successful validation.
	outputPath android.OutputPath
}

func (this *allTestSpecsSingleton) GenerateBuildActions(ctx android.SingletonContext) {
	var intermediateMetadataPaths android.Paths

	ctx.VisitAllModules(func(module android.Module) {
		if !ctx.ModuleHasProvider(module, testSpecProviderKey) {
			return
		}
		intermediateMetadataPaths = append(intermediateMetadataPaths, ctx.ModuleProvider(module, testSpecProviderKey).(testSpecProviderData).IntermediatePath)
	})

	rspFile := android.PathForOutput(ctx, fileContainingFilePaths)
	this.outputPath = android.PathForOutput(ctx, ownershipDirectory, allTestSpecsFile)

	rule := android.NewRuleBuilder(pctx, ctx)
	cmd := rule.Command().
		BuiltTool("metadata").
		FlagWithArg("-rule ", "test_spec").
		FlagWithRspFileInputList("-inputFile ", rspFile, intermediateMetadataPaths)
	cmd.FlagWithOutput("-outputFile ", this.outputPath)
	rule.Build("all_test_specs_rule", "Generate all test specifications")
	ctx.Phony("all_test_specs", this.outputPath)
}

func (this *allTestSpecsSingleton) MakeVars(ctx android.MakeVarsContext) {
	ctx.DistForGoal("test_specs", this.outputPath)
}
+6 −0
Original line number Diff line number Diff line
@@ -18,10 +18,16 @@ import (
	"android/soong/android"
)

var (
	pctx = android.NewPackageContext("android/soong/testing")
)

func init() {
	RegisterBuildComponents(android.InitRegistrationContext)
	pctx.HostBinToolVariable("metadata", "metadata")
}

func RegisterBuildComponents(ctx android.RegistrationContext) {
	ctx.RegisterModuleType("test_spec", TestSpecFactory)
	ctx.RegisterParallelSingletonType("all_test_specs", AllTestSpecsFactory)
}