Skip to content

Commit a802b52

Browse files
committed
fix, Do not allow total tests to be negative for Go
Seems that Go 1.23 has different behavior for test execution reporting.
1 parent 2e21e0c commit a802b52

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

evaluate/task/symflower.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func symflowerTemplate(logger *log.Logger, repositoryPath string, language langu
5959
// ExecuteWithSymflowerFix runs the "symflower fix" command and calculates the new assessments.
6060
func ExecuteWithSymflowerFix(ctx evaltask.Context, logger *log.Logger, packagePath string) (testResult *language.TestResult, processingTime uint64, problems []error, err error) {
6161
// Run "symflower fix" if the model response fails to execute.
62-
logger.Info("model response alone failed execution, attempting to fix with \"symflower fix \"")
62+
logger.Info("model response alone failed execution, attempting to fix with \"symflower fix\"")
6363

6464
duration, err := symflowerFix(logger, packagePath, ctx.Language)
6565
if err != nil {

language/golang/language.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ func parseSymflowerTestOutput(data string) (testsTotal int, testsPass int, err e
140140
}
141141
}
142142
testsPass = testsTotal - testsFail
143+
if testsPass < 0 { // Go does not count tests on syntax errors, but marks it as a failing test. This results in total tests 0 minus failing tess 1, hence, -1. Passing tests should be always >=0.
144+
testsPass = 0
145+
}
143146

144147
return testsTotal, testsPass, nil
145148
}

language/golang/language_test.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,4 +305,27 @@ func TestParseSymflowerTestOutput(t *testing.T) {
305305
ExpectedTestsTotal: 6,
306306
ExpectedTestsPass: 4,
307307
})
308+
validate(t, &testCase{
309+
Name: "Tests with syntax error in implementation (Go >=1.23)",
310+
311+
Data: `
312+
# cascadingIfElse [cascadingIfElse.test]
313+
./cascadingIfElse.go:3:8: "strings" imported and not used
314+
FAIL cascadingIfElse [build failed]
315+
316+
=== Failed
317+
=== FAIL: . (0.00s)
318+
FAIL cascadingIfElse [build failed]
319+
320+
=== Errors
321+
./cascadingIfElse.go:3:8: "strings" imported and not used
322+
323+
DONE 0 tests, 1 failure, 1 error in 0.117s
324+
Give us your feedback and let us know how we can improve Symflower at [email protected] or https://github.com/symflower/symflower. Thanks so much for your help!
325+
ERROR: execution failed: exit status 1
326+
`,
327+
328+
ExpectedTestsTotal: 0,
329+
ExpectedTestsPass: 0,
330+
})
308331
}

0 commit comments

Comments
 (0)