Skip to content

Commit

Permalink
fix: trim empty line in output, add error to start failure
Browse files Browse the repository at this point in the history
  • Loading branch information
j178 committed Jan 8, 2024
1 parent 138e13c commit 8e36149
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lang/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ func extractOutput(s string) (string, string) {
var output string
var others []string
for _, line := range utils.SplitLines(s) {
if strings.TrimSpace(line) == "" {
continue
}
if strings.HasPrefix(line, testCaseOutputMark) {
// If there are multiple output lines, only the last one is used.
output = strings.TrimSpace(line[len(testCaseOutputMark):])
Expand Down Expand Up @@ -194,7 +197,13 @@ func runTest(q *leetcode.QuestionData, genResult *GenerateResult, args []string,
cmd.Stderr = outputBuf
err = cmd.Start()
if err != nil {
l.AppendItem(fmt.Sprintf("Case %d: %s", c.No, config.ErrorStyle.Render("Failed to start")))
l.AppendItem(
fmt.Sprintf(
"Case %d: %s",
c.No,
config.ErrorStyle.Render("Failed to start:", err.Error()),
),
)
return
}
err = cmd.Wait()
Expand Down

0 comments on commit 8e36149

Please sign in to comment.