diff --git a/internal/configuration/configuration_test.go b/internal/configuration/configuration_test.go index b77bd02a..cb2586ef 100644 --- a/internal/configuration/configuration_test.go +++ b/internal/configuration/configuration_test.go @@ -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() @@ -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)) } }) @@ -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)) } }) @@ -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)) } }) } diff --git a/internal/coverage/coverage_test.go b/internal/coverage/coverage_test.go index 03e4a8e8..07756299 100644 --- a/internal/coverage/coverage_test.go +++ b/internal/coverage/coverage_test.go @@ -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)) } }) } diff --git a/internal/engine/executor_test.go b/internal/engine/executor_test.go index 4f5f615c..e5a1c674 100644 --- a/internal/engine/executor_test.go +++ b/internal/engine/executor_test.go @@ -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) diff --git a/internal/engine/tokenmutator_test.go b/internal/engine/tokenmutator_test.go index f2eeb65c..bd209049 100644 --- a/internal/engine/tokenmutator_test.go +++ b/internal/engine/tokenmutator_test.go @@ -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() @@ -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))) } } } diff --git a/internal/engine/workdir/workdir_test.go b/internal/engine/workdir/workdir_test.go index d3745097..d5173b32 100644 --- a/internal/engine/workdir/workdir_test.go +++ b/internal/engine/workdir/workdir_test.go @@ -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 diff --git a/internal/mutator/mutator_test.go b/internal/mutator/mutator_test.go index 397b0ef5..419ee4cd 100644 --- a/internal/mutator/mutator_test.go +++ b/internal/mutator/mutator_test.go @@ -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)) } }) } @@ -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)) } }) } diff --git a/internal/report/logger_test.go b/internal/report/logger_test.go index 8fe632a1..aa673564 100644 --- a/internal/report/logger_test.go +++ b/internal/report/logger_test.go @@ -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)) } } diff --git a/internal/report/report.go b/internal/report/report.go index 3a709a10..12a81c99 100644 --- a/internal/report/report.go +++ b/internal/report/report.go @@ -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) } diff --git a/internal/report/report_test.go b/internal/report/report_test.go index 18f1ab56..e4afb10e 100644 --- a/internal/report/report_test.go +++ b/internal/report/report_test.go @@ -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) @@ -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)) } }) } @@ -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)) } }) } @@ -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") } }) } @@ -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)) } } @@ -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)) } })