From 8e36149c7fda3fa7cc81ea65eceaa3c512df3671 Mon Sep 17 00:00:00 2001 From: j178 <10510431+j178@users.noreply.github.com> Date: Mon, 8 Jan 2024 11:14:05 +0800 Subject: [PATCH] fix: trim empty line in output, add error to start failure --- lang/test.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lang/test.go b/lang/test.go index 5222397f..25c5a837 100644 --- a/lang/test.go +++ b/lang/test.go @@ -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):]) @@ -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()