Skip to content

Commit b966eb4

Browse files
committed
Don't use combined output
1 parent 44f2cb3 commit b966eb4

1 file changed

Lines changed: 2 additions & 16 deletions

File tree

pkg/executor/executor.go

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -81,17 +81,14 @@ func (e *CLIExecutor) Run(apexCode string, org string) (string, error) {
8181

8282
// Execute command
8383
cmd := execCommand("sf", args...)
84-
output, err := cmd.CombinedOutput()
84+
output, err := cmd.Output()
8585
if err != nil {
8686
return "", fmt.Errorf("sf apex run failed: %w\nOutput: %s", err, string(output))
8787
}
8888

89-
// Extract JSON from output (skip warning messages)
90-
jsonOutput := extractJSON(string(output))
91-
9289
// Parse JSON response
9390
var response ApexRunResponse
94-
if err := json.Unmarshal([]byte(jsonOutput), &response); err != nil {
91+
if err := json.Unmarshal(output, &response); err != nil {
9592
return "", fmt.Errorf("failed to parse sf apex run JSON output: %w\nOutput: %s", err, string(output))
9693
}
9794

@@ -162,17 +159,6 @@ func (e *CLIExecutor) ExecuteParallel(apexCode string, runs int, maxConcurrent i
162159
return results, nil
163160
}
164161

165-
// extractJSON finds the first JSON object in the output string
166-
// This handles cases where sf CLI outputs warnings before the JSON
167-
func extractJSON(output string) string {
168-
// Find the first '{' character
169-
start := strings.Index(output, "{")
170-
if start == -1 {
171-
return output
172-
}
173-
return output[start:]
174-
}
175-
176162
// createTempApexFile writes Apex code to a temporary file
177163
func createTempApexFile(apexCode string) (string, error) {
178164
tmpFile, err := os.CreateTemp("", "apex-bench-*.apex")

0 commit comments

Comments
 (0)