Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions internal/configuration/configuration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func TestConfiguration(t *testing.T) {
for key, wanted := range tc.wantedConfig {
got := Get[any](key)
if got != wanted {
t.Errorf(cmp.Diff(got, wanted))
t.Errorf("%s", cmp.Diff(got, wanted))
}
}
viper.Reset()
Expand Down Expand Up @@ -159,7 +159,7 @@ func TestConfigPaths(t *testing.T) {
got := defaultConfigPaths()

if !cmp.Equal(got, want) {
t.Errorf(cmp.Diff(got, want))
t.Errorf("%s", cmp.Diff(got, want))
}
})

Expand Down Expand Up @@ -189,7 +189,7 @@ func TestConfigPaths(t *testing.T) {
got := defaultConfigPaths()

if !cmp.Equal(got, want) {
t.Errorf(cmp.Diff(got, want))
t.Errorf("%s", cmp.Diff(got, want))
}
})

Expand Down Expand Up @@ -225,7 +225,7 @@ func TestConfigPaths(t *testing.T) {
got := defaultConfigPaths()

if !cmp.Equal(got, want) {
t.Errorf(cmp.Diff(got, want))
t.Errorf("%s", cmp.Diff(got, want))
}
})
}
Expand Down
4 changes: 2 additions & 2 deletions internal/coverage/coverage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ func TestCoverageRun(t *testing.T) {
secondGot := fmt.Sprintf("go %v", strings.Join(holder.events[1].args, " "))

if !cmp.Equal(firstGot, firstWant) {
t.Errorf(cmp.Diff(firstGot, firstWant))
t.Errorf("%s", cmp.Diff(firstGot, firstWant))
}
if !cmp.Equal(secondGot, secondWant) {
t.Errorf(cmp.Diff(secondGot, secondWant))
t.Errorf("%s", cmp.Diff(secondGot, secondWant))
}
})
}
Expand Down
2 changes: 1 addition & 1 deletion internal/engine/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ func TestMutatorRun(t *testing.T) {
got := fmt.Sprintf("go %v", strings.Join(holder.args, " "))

if !cmp.Equal(got, want) {
t.Errorf(fmt.Sprintf("\n+ %s\n- %s\n", got, want))
t.Errorf("\n+ %s\n- %s\n", got, want)
}

timeoutDifference := absTimeDiff(holder.timeout, expectedTimeout*2)
Expand Down
4 changes: 2 additions & 2 deletions internal/engine/tokenmutator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func TestMutantApplyAndRollback(t *testing.T) {
t.Fatal(err)
}
if !cmp.Equal(string(got), want[i]) {
t.Fatalf(cmp.Diff(want[i], string(got)))
t.Errorf("%s", cmp.Diff(want[i], string(got)))
}

err = mut.Rollback()
Expand All @@ -93,7 +93,7 @@ func TestMutantApplyAndRollback(t *testing.T) {
t.Fatal(err)
}
if !cmp.Equal(string(got), rollbackWant) {
t.Fatalf(cmp.Diff(rollbackWant, string(got)))
t.Errorf("%s", cmp.Diff(rollbackWant, string(got)))
}
}
}
2 changes: 1 addition & 1 deletion internal/engine/workdir/workdir_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func checkForDifferentFile(t *testing.T, srcDir string, dstDir string) func(path
t.Errorf("expected Name to be %v, got %v", srcFileInfo.Name(), dstFileInfo.Name())
}
if !cmp.Equal(dstFileInfo.Mode(), srcFileInfo.Mode()) {
t.Errorf(cmp.Diff(srcFileInfo.Mode(), dstFileInfo.Mode()))
t.Errorf("%s", cmp.Diff(srcFileInfo.Mode(), dstFileInfo.Mode()))
}

return nil
Expand Down
4 changes: 2 additions & 2 deletions internal/mutator/mutator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func TestStatusString(t *testing.T) {
tc := tc
t.Run(tc.name, func(t *testing.T) {
if tc.mutationStatus.String() != tc.expected {
t.Errorf(cmp.Diff(tc.mutationStatus.String(), tc.expected))
t.Errorf("%s", cmp.Diff(tc.mutationStatus.String(), tc.expected))
}
})
}
Expand Down Expand Up @@ -137,7 +137,7 @@ func TestTypeString(t *testing.T) {
tc := tc
t.Run(tc.name, func(t *testing.T) {
if tc.mutantType.String() != tc.expected {
t.Errorf(cmp.Diff(tc.mutantType.String(), tc.expected))
t.Errorf("%s", cmp.Diff(tc.mutantType.String(), tc.expected))
}
})
}
Expand Down
2 changes: 1 addition & 1 deletion internal/report/logger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,6 @@ func TestLogger(t *testing.T) {
" LIVED CONDITIONALS_BOUNDARY at aFolder/aFile.go:12:3\n"

if !cmp.Equal(got, want) {
t.Errorf(cmp.Diff(got, want))
t.Errorf("%s", cmp.Diff(got, want))
}
}
4 changes: 2 additions & 2 deletions internal/report/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,14 +233,14 @@ func (r *reportStatus) assess(tEfficacy, rCoverage float64) error {
if et == 0 {
et = float64(configuration.Get[int](configuration.UnleashThresholdEfficacyKey))
}
if et > 0 && tEfficacy <= et {
if et > 0 && tEfficacy < et {
return execution.NewExitErr(execution.EfficacyThreshold)
}
ct := configuration.Get[float64](configuration.UnleashThresholdMCoverageKey)
if ct == 0 {
ct = float64(configuration.Get[int](configuration.UnleashThresholdMCoverageKey))
}
if ct > 0 && rCoverage <= ct {
if ct > 0 && rCoverage < ct {
return execution.NewExitErr(execution.MutantCoverageThreshold)
}

Expand Down
35 changes: 18 additions & 17 deletions internal/report/report_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ import (
"github.com/hectane/go-acl"
"github.com/spf13/viper"

"github.com/go-gremlins/gremlins/internal/execution"
"github.com/go-gremlins/gremlins/internal/log"
"github.com/go-gremlins/gremlins/internal/mutator"
"github.com/go-gremlins/gremlins/internal/report"
"github.com/go-gremlins/gremlins/internal/report/internal"

"github.com/go-gremlins/gremlins/internal/configuration"
"github.com/go-gremlins/gremlins/internal/execution"
)

var fakePosition = newPosition("aFolder/aFile.go", 3, 12)
Expand Down Expand Up @@ -122,7 +122,7 @@ func TestReport(t *testing.T) {
got := out.String()

if !cmp.Equal(got, tc.want) {
t.Errorf(cmp.Diff(tc.want, got))
t.Errorf("%s", cmp.Diff(tc.want, got))
}
})
}
Expand Down Expand Up @@ -176,7 +176,7 @@ func TestReport(t *testing.T) {
got := out.String()

if !cmp.Equal(got, tc.want) {
t.Errorf(cmp.Diff(tc.want, got))
t.Errorf("%s", cmp.Diff(tc.want, got))
}
})
}
Expand Down Expand Up @@ -275,19 +275,20 @@ func TestAssessment(t *testing.T) {

err := report.Do(data)

if tc.expectError && err == nil {
t.Fatal("expected an error")
}
if !tc.expectError {
return
}
var exitErr *execution.ExitError
if errors.As(err, &exitErr) {
if exitErr.ExitCode() == 0 {
t.Errorf("expected exit code to be different from 0, got %d", exitErr.ExitCode())
if tc.expectError {
if err == nil {
t.Fatal("expected an error")
}
var exitErr *execution.ExitError
if errors.As(err, &exitErr) {
if exitErr.ExitCode() == 0 {
t.Errorf("expected exit code to be different from 0, got %d", exitErr.ExitCode())
}
} else {
t.Errorf("expected err to be ExitError")
}
} else {
t.Errorf("expected err to be ExitError")
} else if err != nil {
t.Fatal("unexpected error")
}
})
}
Expand Down Expand Up @@ -326,7 +327,7 @@ func TestMutantLog(t *testing.T) {
" SKIPPED CONDITIONALS_BOUNDARY at aFolder/aFile.go:12:3\n"

if !cmp.Equal(got, want) {
t.Errorf(cmp.Diff(got, want))
t.Errorf("%s", cmp.Diff(got, want))
}
}

Expand Down Expand Up @@ -377,7 +378,7 @@ func TestReportToFile(t *testing.T) {
}

if !cmp.Equal(got, want, cmpopts.SortSlices(sortOutputFile), cmpopts.SortSlices(sortMutation)) {
t.Errorf(cmp.Diff(got, want))
t.Errorf("%s", cmp.Diff(got, want))
}
})

Expand Down