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
41 changes: 41 additions & 0 deletions .github/workflows/mutation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Mutation Testing

on:
push:
branches: [master]

permissions:
contents: read

jobs:
mutation:
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5
with:
go-version-file: go.mod

- name: Build go-mutesting
run: go build -o /usr/local/bin/go-mutesting ./cmd/go-mutesting

- name: Run mutation testing
# Scoped to packages with isolated unit tests.
# Excluded:
# cmd/ - integration tests re-invoke the binary (would recurse)
# internal/annotation - build errors prevent compilation
# internal/importing - relies on GOPATH/src layout; fails in module mode
# internal/parser - uses deprecated go/loader; excluded until migration
# The tool always exits 0 regardless of mutation score, so this step is
# informational. Check report.json for the full breakdown.
run: |
go-mutesting \
--exec-timeout 30 \
github.com/avito-tech/go-mutesting/mutator/arithmetic \
github.com/avito-tech/go-mutesting/mutator/branch \
github.com/avito-tech/go-mutesting/mutator/expression \
github.com/avito-tech/go-mutesting/mutator/loop \
github.com/avito-tech/go-mutesting/mutator/numbers \
github.com/avito-tech/go-mutesting/mutator/statement \
github.com/avito-tech/go-mutesting/internal/filter
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,9 @@ _testmain.go
*.exe
*.test
*.prof

# go-mutesting build output and run artifacts
/go-mutesting
report.json
report.html
*.go.new
26 changes: 26 additions & 0 deletions internal/filter/skip_mutation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,32 @@ func TestSkipMutationForInitSlicesAndMaps(t *testing.T) {
expectedLiterals: []string{"3", "2", "4"},
expectedOperators: []string{"+", "*"},
},
{
// make(MySlice) with one arg is syntactically valid for the parser even though
// the type-checker would reject it; it exercises the len(Args) > 1 guard.
name: "do not skip mutation for single-arg make with type alias",
code: `package main; type MySlice []int; var a = make(MySlice)`,
expectedLiterals: []string{},
expectedOperators: []string{},
},
{
name: "skip mutation for unary negation of complex inner expression",
code: `package main; var a = make([]int, 0, -(2+3))`,
expectedLiterals: []string{"0", "2", "3"},
expectedOperators: []string{"+"},
},
{
name: "skip mutation for nested call with multiple int args",
code: `package main; var a = make([]int, someFunc(2, 3))`,
expectedLiterals: []string{"2", "3"},
expectedOperators: []string{},
},
{
name: "do not skip mutation for unary on float literals",
code: `package main; var a = make([]float64, -1.5, +2.3)`,
expectedLiterals: []string{},
expectedOperators: []string{},
},
}

for _, tt := range tests {
Expand Down