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

Commit ce39f835 authored by Sam Delmerico's avatar Sam Delmerico
Browse files

add error handling to cquery in MockBazelContext

Change-Id: Ia01072b6528caff2f3ceaca67cdba8b900924fe5
parent 2d0349f1
Loading
Loading
Loading
Loading
+20 −5
Original line number Diff line number Diff line
@@ -233,27 +233,42 @@ func (m MockBazelContext) QueueBazelRequest(_ string, _ cqueryRequest, _ configK
}

func (m MockBazelContext) GetOutputFiles(label string, _ configKey) ([]string, error) {
	result, _ := m.LabelToOutputFiles[label]
	result, ok := m.LabelToOutputFiles[label]
	if !ok {
		return []string{}, fmt.Errorf("no target with label %q in LabelToOutputFiles", label)
	}
	return result, nil
}

func (m MockBazelContext) GetCcInfo(label string, _ configKey) (cquery.CcInfo, error) {
	result, _ := m.LabelToCcInfo[label]
	result, ok := m.LabelToCcInfo[label]
	if !ok {
		return cquery.CcInfo{}, fmt.Errorf("no target with label %q in LabelToCcInfo", label)
	}
	return result, nil
}

func (m MockBazelContext) GetPythonBinary(label string, _ configKey) (string, error) {
	result, _ := m.LabelToPythonBinary[label]
	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, _ := m.LabelToApexInfo[label]
	result, ok := m.LabelToApexInfo[label]
	if !ok {
		return cquery.ApexInfo{}, fmt.Errorf("no target with label %q in LabelToApexInfo", label)
	}
	return result, nil
}

func (m MockBazelContext) GetCcUnstrippedInfo(label string, _ configKey) (cquery.CcUnstrippedInfo, error) {
	result, _ := m.LabelToCcBinary[label]
	result, ok := m.LabelToCcBinary[label]
	if !ok {
		return cquery.CcUnstrippedInfo{}, fmt.Errorf("no target with label %q in LabelToCcBinary", label)
	}
	return result, nil
}