Merge "Remove GetPythonBinary request type"

This commit is contained in:
Treehugger Robot
2023-05-23 21:42:31 +00:00
committed by Gerrit Code Review
3 changed files with 0 additions and 81 deletions

View File

@@ -181,10 +181,6 @@ type BazelContext interface {
// Returns the results of GetOutputFiles and GetCcObjectFiles in a single query (in that order).
GetCcInfo(label string, cfgKey configKey) (cquery.CcInfo, error)
// Returns the executable binary resultant from building together the python sources
// TODO(b/232976601): Remove.
GetPythonBinary(label string, cfgKey configKey) (string, error)
// Returns the results of the GetApexInfo query (including output files)
GetApexInfo(label string, cfgkey configKey) (cquery.ApexInfo, error)
@@ -313,14 +309,6 @@ func (m MockBazelContext) GetCcInfo(label string, cfgKey configKey) (cquery.CcIn
return result, nil
}
func (m MockBazelContext) GetPythonBinary(label string, _ configKey) (string, error) {
result, ok := m.LabelToPythonBinary[label]
if !ok {
return "", fmt.Errorf("no target with label %q in LabelToPythonBinary", label)
}
return result, nil
}
func (m MockBazelContext) GetApexInfo(label string, _ configKey) (cquery.ApexInfo, error) {
result, ok := m.LabelToApexInfo[label]
if !ok {
@@ -429,15 +417,6 @@ func (bazelCtx *mixedBuildBazelContext) GetCcInfo(label string, cfgKey configKey
return cquery.CcInfo{}, fmt.Errorf("no bazel response found for %v", key)
}
func (bazelCtx *mixedBuildBazelContext) GetPythonBinary(label string, cfgKey configKey) (string, error) {
key := makeCqueryKey(label, cquery.GetPythonBinary, cfgKey)
if rawString, ok := bazelCtx.results[key]; ok {
bazelOutput := strings.TrimSpace(rawString)
return cquery.GetPythonBinary.ParseResult(bazelOutput), nil
}
return "", fmt.Errorf("no bazel response found for %v", key)
}
func (bazelCtx *mixedBuildBazelContext) GetApexInfo(label string, cfgKey configKey) (cquery.ApexInfo, error) {
key := makeCqueryKey(label, cquery.GetApexInfo, cfgKey)
if rawString, ok := bazelCtx.results[key]; ok {
@@ -466,10 +445,6 @@ func (n noopBazelContext) GetCcInfo(_ string, _ configKey) (cquery.CcInfo, error
panic("unimplemented")
}
func (n noopBazelContext) GetPythonBinary(_ string, _ configKey) (string, error) {
panic("unimplemented")
}
func (n noopBazelContext) GetApexInfo(_ string, _ configKey) (cquery.ApexInfo, error) {
panic("unimplemented")
}

View File

@@ -8,7 +8,6 @@ import (
var (
GetOutputFiles = &getOutputFilesRequestType{}
GetPythonBinary = &getPythonBinaryRequestType{}
GetCcInfo = &getCcInfoType{}
GetApexInfo = &getApexInfoType{}
GetCcUnstrippedInfo = &getCcUnstrippedInfoType{}
@@ -45,8 +44,6 @@ type CcInfo struct {
type getOutputFilesRequestType struct{}
type getPythonBinaryRequestType struct{}
// Name returns a string name for this request type. Such request type names must be unique,
// and must only consist of alphanumeric characters.
func (g getOutputFilesRequestType) Name() string {
@@ -72,31 +69,6 @@ func (g getOutputFilesRequestType) ParseResult(rawString string) []string {
return splitOrEmpty(rawString, ", ")
}
// Name returns a string name for this request type. Such request type names must be unique,
// and must only consist of alphanumeric characters.
func (g getPythonBinaryRequestType) Name() string {
return "getPythonBinary"
}
// StarlarkFunctionBody returns a starlark function body to process this request type.
// The returned string is the body of a Starlark function which obtains
// all request-relevant information about a target and returns a string containing
// this information.
// The function should have the following properties:
// - The arguments are `target` (a configured target) and `id_string` (the label + configuration).
// - The return value must be a string.
// - The function body should not be indented outside of its own scope.
func (g getPythonBinaryRequestType) StarlarkFunctionBody() string {
return "return providers(target)['FilesToRunProvider'].executable.path"
}
// ParseResult returns a value obtained by parsing the result of the request's Starlark function.
// The given rawString must correspond to the string output which was created by evaluating the
// Starlark given in StarlarkFunctionBody.
func (g getPythonBinaryRequestType) ParseResult(rawString string) string {
return rawString
}
type getCcInfoType struct{}
// Name returns a string name for this request type. Such request type names must be unique,

View File

@@ -40,34 +40,6 @@ func TestGetOutputFilesParseResults(t *testing.T) {
}
}
func TestGetPythonBinaryParseResults(t *testing.T) {
t.Parallel()
testCases := []struct {
description string
input string
expectedOutput string
}{
{
description: "no result",
input: "",
expectedOutput: "",
},
{
description: "one result",
input: "test",
expectedOutput: "test",
},
}
for _, tc := range testCases {
t.Run(tc.description, func(t *testing.T) {
actualOutput := GetPythonBinary.ParseResult(tc.input)
if !reflect.DeepEqual(tc.expectedOutput, actualOutput) {
t.Errorf("expected %#v != actual %#v", tc.expectedOutput, actualOutput)
}
})
}
}
func TestGetCcInfoParseResults(t *testing.T) {
t.Parallel()
testCases := []struct {