exercism / go-test-runner

GNU Affero General Public License v3.0
15 stars 17 forks source link

Unspecific error messages if the code does not compile #39

Closed junedev closed 2 years ago

junedev commented 2 years ago

In the editor bug reports a lot of people wrote they saw '/usr/local/go/bin/go test --json .' returned exit code 2: exit status 2 as error message which wasn't helpful for them. Is there something that could be improved?

I also see the generic "an error occurred" for certain solutions.

I will post some examples below.
My feeling is this happens when the (test) code does not compile.

junedev commented 2 years ago

Example 1

Running the tests on the website against the current lasagna stub:

package lasagna

// TODO: define the 'OvenTime' constant

// TODO: define the 'RemainingOvenTime()' function

// TODO: define the 'PreparationTime()' function

// TODO: define the 'ElapsedTime()' function

image

junedev commented 2 years ago

Example 2

Typo on the package name

package lasagnaaaa

// OvenTime represents the expected baking time in minutes.
const OvenTime = 40

// RemainingOvenTime returns the remaining minutes based on the `actual` minutes already in the oven.
func RemainingOvenTime(actual int) int {
    return OvenTime - actual
}

// PreparationTime calculates the time needed to prepare the lasagna based on the amount of layers.
func PreparationTime(numberOfLayers int) int {
    return numberOfLayers * 2
}

// ElapsedTime calculates the total time needed to create and bake a lasagna.
func ElapsedTime(numberOfLayers, actualMinutesInOven int) int {
    return PreparationTime(numberOfLayers) + actualMinutesInOven
}

image

junedev commented 2 years ago

Example 3

Missing variable (here I deleted the OvenTime constant):

package lasagna

// RemainingOvenTime returns the remaining minutes based on the `actual` minutes already in the oven.
func RemainingOvenTime(actual int) int {
    return OvenTime - actual
}

// PreparationTime calculates the time needed to prepare the lasagna based on the amount of layers.
func PreparationTime(numberOfLayers int) int {
    return numberOfLayers * 2
}

// ElapsedTime calculates the total time needed to create and bake a lasagna.
func ElapsedTime(numberOfLayers, actualMinutesInOven int) int {
    return PreparationTime(numberOfLayers) + actualMinutesInOven
}

image

junedev commented 2 years ago

Example 4

Missing function (here I deleted RemainingOvenTime):

package lasagna

// OvenTime represents the expected baking time in minutes.
const OvenTime = 40

// PreparationTime calculates the time needed to prepare the lasagna based on the amount of layers.
func PreparationTime(numberOfLayers int) int {
    return numberOfLayers * 2
}

// ElapsedTime calculates the total time needed to create and bake a lasagna.
func ElapsedTime(numberOfLayers, actualMinutesInOven int) int {
    return PreparationTime(numberOfLayers) + actualMinutesInOven
}

image

junedev commented 2 years ago

I narrowed it down a bit. I found out that the actual compiler error is written to stderr but we only return what was written to stdout currently.

junedev commented 2 years ago

It turned out there were two issues here:

The PR fixes both issues.