Skip to content

Commit

Permalink
fix: retract version v0.3.0; it has an issue that prevents Ooze from …
Browse files Browse the repository at this point in the history
…running

After introducing #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:  #9
  • Loading branch information
gtramontina committed May 4, 2023
1 parent c15ffee commit d024c0c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 19 deletions.
6 changes: 6 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 1 addition & 17 deletions internal/gosourcefile/gosourcefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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))
}

Expand Down
2 changes: 0 additions & 2 deletions release.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -59,7 +58,6 @@ var defaultOptions = Options{ //nolint:gochecknoglobals
arithmeticassignment.New(),
arithmeticassignmentinvert.New(),
bitwise.New(),
cancelnil.New(),
comparison.New(),
comparisoninvert.New(),
comparisonreplace.New(),
Expand Down
1 change: 1 addition & 0 deletions viruses/cancelnil/cancelnil_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down

0 comments on commit d024c0c

Please sign in to comment.