From d024c0c892d15882440e3e0b63ab7fbf8c63d617 Mon Sep 17 00:00:00 2001 From: "Guilherme J. Tramontina" Date: Thu, 4 May 2023 10:45:08 +1000 Subject: [PATCH] fix: retract version v0.3.0; it has an issue that prevents Ooze from running After introducing https://github.com/gtramontina/ooze/pull/5, running mutation tests against Ooze itself (and I think it is safe to assume that other projects too) fails with the following (or similar) error: ``` Error: panic: failed type checking for file 'internal/cmdtestrunner/cmdtestrunner.go': internal/cmdtestrunner/cmdtestrunner.go:7:2: could not import github.com/gtramontina/ooze/internal/ooze (can't find import: "github.com/gtramontina/ooze/internal/ooze") goroutine 6 [running]: testing.tRunner.func1.2({0x6ef2c0, 0xc000202d20}) /opt/hostedtoolcache/go/1.18.10/x64/src/testing/testing.go:1389 +0x[24](https://github.com/gtramontina/ooze/actions/runs/4843531326/jobs/8631215763#step:4:25)e testing.tRunner.func1() /opt/hostedtoolcache/go/1.18.10/x64/src/testing/testing.go:1392 +0x39f panic({0x6ef2c0, 0xc000202d20}) /opt/hostedtoolcache/go/1.18.10/x64/src/runtime/panic.go:838 +0x207 github.com/gtramontina/ooze/internal/gosourcefile.(*GoSourceFile).Incubate(0xc000124bd0, {0x7ab3e0?, 0xc000010078}) /home/runner/work/ooze/ooze/internal/gosourcefile/gosourcefile.go:46 +0x453 github.com/gtramontina/ooze/internal/ooze.(*Ooze).Release(0xc0001dfe50, {0x95f6e0, 0xe, 0xc0000b7e30?}) /home/runner/work/ooze/ooze/internal/ooze/ooze.go:83 +0x2[25](https://github.com/gtramontina/ooze/actions/runs/4843531326/jobs/8631215763#step:4:26) github.com/gtramontina/ooze.Release(0xc000097860, {0xc0000b7f[30](https://github.com/gtramontina/ooze/actions/runs/4843531326/jobs/8631215763#step:4:31), 0x6, 0x3a?}) /home/runner/work/ooze/ooze/release.go:138 +0xa3a github.com/gtramontina/ooze_test.TestMutation(0x0?) /home/runner/work/ooze/ooze/ooze_mutation_test.go:12 +0xeb testing.tRunner(0xc000097860, 0x75a558) /opt/hostedtoolcache/go/1.18.10/x64/src/testing/testing.go:1439 +0x102 created by testing.(*T).Run /opt/hostedtoolcache/go/1.18.10/x64/src/testing/testing.go:1486 +0x[35](https://github.com/gtramontina/ooze/actions/runs/4843531326/jobs/8631215763#step:4:36)f ``` More info: https://github.com/gtramontina/ooze/issues/9 --- go.mod | 6 ++++++ internal/gosourcefile/gosourcefile.go | 18 +----------------- release.go | 2 -- viruses/cancelnil/cancelnil_test.go | 1 + 4 files changed, 8 insertions(+), 19 deletions(-) diff --git a/go.mod b/go.mod index cdd2aee..4a9cac4 100644 --- a/go.mod +++ b/go.mod @@ -2,6 +2,12 @@ module github.com/gtramontina/ooze go 1.20 +retract ( + // This version contains an issue that prevents Ooze from running on + // internal packages. See https://github.com/gtramontina/ooze/issues/9. + v0.3.0 +) + require ( github.com/fatih/color v1.15.0 github.com/hexops/gotextdiff v1.0.3 diff --git a/internal/gosourcefile/gosourcefile.go b/internal/gosourcefile/gosourcefile.go index 33aef18..54b8156 100644 --- a/internal/gosourcefile/gosourcefile.go +++ b/internal/gosourcefile/gosourcefile.go @@ -3,10 +3,8 @@ package gosourcefile import ( "fmt" "go/ast" - "go/importer" "go/parser" "go/token" - "go/types" "github.com/gtramontina/ooze/internal/goinfectedfile" "github.com/gtramontina/ooze/viruses" @@ -32,24 +30,10 @@ func (f *GoSourceFile) Incubate(virus viruses.Virus) []*goinfectedfile.GoInfecte panic(fmt.Errorf("failed parsing file '%s': %w", f.relativePath, err)) } - cfg := types.Config{ //nolint:exhaustruct // default values for missing fields are okay - Importer: importer.Default(), - } - - info := types.Info{ //nolint:exhaustruct // Info.TypeOf needs Defs, Uses, and Types populated, we don't need the rest - Defs: map[*ast.Ident]types.Object{}, - Uses: map[*ast.Ident]types.Object{}, - Types: map[ast.Expr]types.TypeAndValue{}, - } - - if _, err := cfg.Check(f.relativePath, fileSet, []*ast.File{fileTree}, &info); err != nil { - panic(fmt.Errorf("failed type checking for file '%s': %w", f.relativePath, err)) - } - var infectedFiles []*goinfectedfile.GoInfectedFile ast.Inspect(fileTree, func(node ast.Node) bool { - for _, infection := range virus.Incubate(node, &info) { + for _, infection := range virus.Incubate(node, nil) { infectedFiles = append(infectedFiles, goinfectedfile.New(f.relativePath, f.rawContent, infection, fileSet, fileTree)) } diff --git a/release.go b/release.go index 01936a7..f90669b 100644 --- a/release.go +++ b/release.go @@ -28,7 +28,6 @@ import ( "github.com/gtramontina/ooze/viruses/arithmeticassignment" "github.com/gtramontina/ooze/viruses/arithmeticassignmentinvert" "github.com/gtramontina/ooze/viruses/bitwise" - "github.com/gtramontina/ooze/viruses/cancelnil" "github.com/gtramontina/ooze/viruses/comparison" "github.com/gtramontina/ooze/viruses/comparisoninvert" "github.com/gtramontina/ooze/viruses/comparisonreplace" @@ -59,7 +58,6 @@ var defaultOptions = Options{ //nolint:gochecknoglobals arithmeticassignment.New(), arithmeticassignmentinvert.New(), bitwise.New(), - cancelnil.New(), comparison.New(), comparisoninvert.New(), comparisonreplace.New(), diff --git a/viruses/cancelnil/cancelnil_test.go b/viruses/cancelnil/cancelnil_test.go index d0f6972..92e2587 100644 --- a/viruses/cancelnil/cancelnil_test.go +++ b/viruses/cancelnil/cancelnil_test.go @@ -8,6 +8,7 @@ import ( ) func TestCancelNil(t *testing.T) { + t.Skip("temporarily: https://github.com/gtramontina/ooze/pull/10") oozetesting.Run(t, oozetesting.NewScenarios( "Call cancel(nil)", cancelnil.New(),