Go - Tests passing for solutions that don't compile
Closed this issue · 10 comments
I noticed that for some solutions I'm mentoring, there's the little icon at the top saying the tests passed but the solutions don't even compile. I noticed this on the Go track on 2 different exercises, there might be happening in more.
@exercism/go
@ErikSchierboom
cc @exercism/go
FYI, I just got the same for this code that has a comma in the factored import statement and is missing a comma in a map initializer, both of which were flagged as errors locally.
// Package scrabble helps calculate Scrabble scores.
package scrabble
import
(
"strings",
"fmt"
)
// Score calculates the score of a word in Scrabble.
func Score(word string) int {
values := map[int]string{
1: "AEIOULNRST",
2: "DG",
3: "BCMP",
5: "K",
8: "JX",
10: "QZ"
}
word := strings.ToUpper(word)
var score int
for _, letter := range word {
for valIndex, value := range values {
if strings.Contains(value, string(letter)) {
score += valIndex
}
}
}
return score
}
Using @bobahop's sample code, I can confirm that there is indeed a bug in the test runner. I copied the above code into the stub of the scrabble score exercise, and then ran go test
locally:
erik@VELPIE:~/exercism/go/exercises/practice/scrabble-score$ go test
can't load package: package scrabble:
scrabble_score.go:5:14: expected ';', found ','
I then ran the test runner using ./bin/run-in-docker.sh scrabble-score /home/erik/exercism/go/exercises/practice/scrabble-score /home/erik/exercism/go/exercises/practice/scrabble-score
, which output the following results.json
file:
{
"status": "pass",
"version": 2,
"tests": []
}
CC @tehsphinx
Also, the bottom line here
func Score(word string) int {
. . .
word := strings.ToUpper(word)
generates the error
no new variables on left side of :=
go test
will return 1 on build failures too.
We need to differentiate the two causes of failure.
I can put up a PR later today.
@moshegood Brilliant! That would be much appreciated
@bobahop @andrerfcsantos A new version of the test runner has been released that fixes this (courtesy of @moshegood). Would you mind testing it, and if it works, close this issue?
I think this is working now. I did a quick test and the tests now fail for solutions that don't compile. I also haven't seen this problem anymore in students solutions. I'll close this issue. Feel free to add additional commentaries or re-open the issue if necessary.
Thanks for updating!