steps.go's StageYaegiGate tells the operator to migrate the deleted
.archie/gate.go hook to a registered YAML workflow step, and
BuiltinStepRegistry() exposed only the six shipped workflows' own stages,
so there was nothing to migrate to. What that hook did, from 924b02a1
which deleted it: it read the worktree's repository-authored Go,
exporting Check(GateContext{Diff, ChangedFiles, Dir, BaseRef, Repo})
[]Finding, where each Finding carried a level ("error" blocked the run,
"warn" was advisory) and an optional file and line, and it inspected the
committed diff.
gate.diff-rules is that behaviour as a typed step: operator-written rules
in a stored definition -- per-rule level, RE2 pattern, optional path and
exclude_path scope, message -- matched against the ADDED lines of the
diff against the base branch, reported with their new-file line numbers.
An error-level finding parks the run with the findings in the park
reason; a warn-level finding is logged and nothing else. Unlike the hook
it replaces, no code is read out of the repository being worked on, and
the rules are versioned and audited with the definition they live in.
The settings are validated at the factory, which runs where a definition
is validated and again where it is compiled: a missing level, pattern or
message, an unknown level or settings key, and an expression that is not
a RE2 all refuse the definition rather than load and check nothing.
It arrives through the extension point archie-core-fwmp landed: a
repo-hooks provider in internal/infrastructure/workflowsteps, so both
roots that resolve a step type (the State Store's validating side and the
daemon's workflow-definitions client) register it at once.
Deliberately not landed: a step type for .archie/stages/*.go, whose
faithful equivalent is running a configured command. That would make the
stored workflow-definitions resource a command-execution surface on the
agent host, which is a maintainer's trust decision, not this lane's; it
is escalated, so steps.go's repo-stages error stays as it is.
527 lines
18 KiB
Go
527 lines
18 KiB
Go
package workflow
|
|
|
|
import (
|
|
"bytes"
|
|
"context"
|
|
"errors"
|
|
"log/slog"
|
|
"os"
|
|
"path/filepath"
|
|
"strings"
|
|
"testing"
|
|
|
|
"gopkg.in/yaml.v3"
|
|
|
|
"github.com/samcharles93/archie-core/internal/config"
|
|
"github.com/samcharles93/archie-core/internal/worktree"
|
|
)
|
|
|
|
// errDiffUnavailable is what a Trees implementation reports when the committed
|
|
// change could not be read.
|
|
var errDiffUnavailable = errors.New("diff unavailable")
|
|
|
|
// diffTwoFiles is a committed change whose added lines carry every position a
|
|
// rule's file/line attribution can get wrong: two hunks in one Go file, a match
|
|
// on an added line in each, a removed line that matches (and must not be
|
|
// reported, because a removed line has no new-file position), a CONTEXT line
|
|
// that matches (and must not be reported, because the rules read what the
|
|
// change adds), and a second file whose added line matches.
|
|
const diffTwoFiles = `diff --git a/main.go b/main.go
|
|
index 1111111..2222222 100644
|
|
--- a/main.go
|
|
+++ b/main.go
|
|
@@ -1,4 +1,5 @@
|
|
package main
|
|
-func greet() { println("hi") }
|
|
+func greet() { println("hi") }
|
|
+func boom() { panic("boom") }
|
|
// panic( mentioned in a kept comment
|
|
func main() { greet() }
|
|
@@ -20,3 +22,3 @@ func tail() {
|
|
keep(t)
|
|
- panic("old")
|
|
+ panic("later")
|
|
}
|
|
diff --git a/notes.md b/notes.md
|
|
index 3333333..4444444 100644
|
|
--- a/notes.md
|
|
+++ b/notes.md
|
|
@@ -1,1 +1,2 @@
|
|
# notes
|
|
+panic( in a doc line
|
|
`
|
|
|
|
// diffTestFile is a change whose only matching added line is in a _test.go
|
|
// file, so a rule's exclude_path is the difference between parking and not.
|
|
const diffTestFile = `diff --git a/main_test.go b/main_test.go
|
|
index 5555555..6666666 100644
|
|
--- a/main_test.go
|
|
+++ b/main_test.go
|
|
@@ -1,1 +1,2 @@
|
|
package main
|
|
+func TestBoom(t *testing.T) { panic("boom") }
|
|
`
|
|
|
|
// stepSettingsNode decodes a step's settings the way ParseDefinition hands them
|
|
// to a factory. An empty src is the zero Node a step written without a settings
|
|
// key carries, which is not the same value as an empty mapping.
|
|
func stepSettingsNode(t *testing.T, src string) yaml.Node {
|
|
t.Helper()
|
|
if src == "" {
|
|
return yaml.Node{}
|
|
}
|
|
var document yaml.Node
|
|
if err := yaml.Unmarshal([]byte(src), &document); err != nil {
|
|
t.Fatalf("parse settings YAML: %v", err)
|
|
}
|
|
if len(document.Content) != 1 {
|
|
t.Fatalf("settings YAML decoded to %d nodes, want one", len(document.Content))
|
|
}
|
|
return *document.Content[0]
|
|
}
|
|
|
|
// diffRulesStage builds the stage through the registered step type's factory,
|
|
// so no test can drive a stage the YAML route could not compile.
|
|
func diffRulesStage(t *testing.T, settingsYAML string) (Stage, error) {
|
|
t.Helper()
|
|
return DiffRulesStepType().Factory(stepSettingsNode(t, settingsYAML))
|
|
}
|
|
|
|
// diffRulesTaskContext is the minimum a diff-rules stage runs against: a
|
|
// prepared worktree, a base branch to diff against, and a log to read back.
|
|
func diffRulesTaskContext(diff string, log *bytes.Buffer) *TaskContext {
|
|
return &TaskContext{
|
|
Task: &Task{ID: 1, Owner: "acme", Repo: "todo", IssueNumber: 42},
|
|
Repo: config.Repo{Owner: "acme", Name: "todo", Base: "main"},
|
|
Trees: &fakeTrees{diff: diff},
|
|
Dir: "/tmp/diff-rules-worktree",
|
|
Log: slog.New(slog.NewTextHandler(log, nil)),
|
|
}
|
|
}
|
|
|
|
// TestDiffRulesStepTypeIsRegisteredAndNamesItself pins the identity the
|
|
// vocabulary is keyed on: the word an operator writes in YAML, and the stage
|
|
// name that appears in the run's events -- they are the same name, so a
|
|
// workflow definition and the timeline agree about which step ran.
|
|
func TestDiffRulesStepTypeIsRegisteredAndNamesItself(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
stepType := DiffRulesStepType()
|
|
if stepType.Name != DiffRulesStepName {
|
|
t.Errorf("step type name = %q, want %q", stepType.Name, DiffRulesStepName)
|
|
}
|
|
if DiffRulesStepName != "gate.diff-rules" {
|
|
t.Errorf("DiffRulesStepName = %q, want the registered vocabulary word %q", DiffRulesStepName, "gate.diff-rules")
|
|
}
|
|
stage, err := diffRulesStage(t, "rules:\n - level: error\n pattern: 'panic\\('\n message: no new panic\n")
|
|
if err != nil {
|
|
t.Fatalf("factory: %v", err)
|
|
}
|
|
if stage.Name != stepType.Name {
|
|
t.Errorf("compiled stage = %q, want the step type's own name %q", stage.Name, stepType.Name)
|
|
}
|
|
if stage.Run == nil {
|
|
t.Error("compiled stage has no Run: it would silently do nothing")
|
|
}
|
|
}
|
|
|
|
// TestDiffRulesStepRefusesSettingsItCannotApply is the validation contract, and
|
|
// it is where invalid state has to be refused: a stored definition that reaches
|
|
// a run is compiled on the executing side, so a setting this step cannot apply
|
|
// must fail at the factory -- during validation and compile -- rather than be
|
|
// quietly dropped when the stage runs.
|
|
func TestDiffRulesStepRefusesSettingsItCannotApply(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
tests := []struct {
|
|
name string
|
|
settings string
|
|
want string
|
|
}{
|
|
{
|
|
name: "no settings at all",
|
|
want: "requires settings",
|
|
},
|
|
{
|
|
name: "no rules",
|
|
settings: "rules: []",
|
|
want: "at least one rule",
|
|
},
|
|
{
|
|
name: "rules key with no rules in it",
|
|
settings: "rules:",
|
|
want: "at least one rule",
|
|
},
|
|
{
|
|
name: "settings that are not a mapping",
|
|
settings: "- rules",
|
|
want: DiffRulesStepName + " settings",
|
|
},
|
|
{
|
|
name: "settings that are a scalar",
|
|
settings: "just text",
|
|
want: DiffRulesStepName + " settings",
|
|
},
|
|
{
|
|
name: "unknown settings key",
|
|
settings: "rulez:\n - level: error\n pattern: 'x'\n message: m\n",
|
|
want: "rulez",
|
|
},
|
|
{
|
|
name: "rule with no level",
|
|
settings: "rules:\n - pattern: 'x'\n message: m\n",
|
|
want: "level is required",
|
|
},
|
|
{
|
|
name: "rule with an unknown level",
|
|
settings: "rules:\n - level: fatal\n pattern: 'x'\n message: m\n",
|
|
want: `unknown level "fatal"`,
|
|
},
|
|
{
|
|
name: "rule with an unknown key",
|
|
settings: "rules:\n - level: error\n pattern: 'x'\n message: m\n severity: high\n",
|
|
want: "severity",
|
|
},
|
|
{
|
|
name: "rule with no pattern",
|
|
settings: "rules:\n - level: error\n message: m\n",
|
|
want: "pattern is required",
|
|
},
|
|
{
|
|
name: "rule with a pattern that is not a regex",
|
|
settings: "rules:\n - level: error\n pattern: 'panic('\n message: m\n",
|
|
want: "pattern",
|
|
},
|
|
{
|
|
name: "rule with no message",
|
|
settings: "rules:\n - level: error\n pattern: 'x'\n",
|
|
want: "message is required",
|
|
},
|
|
{
|
|
name: "rule with a path that is not a regex",
|
|
settings: "rules:\n - level: error\n pattern: 'x'\n message: m\n path: '('\n",
|
|
want: "path",
|
|
},
|
|
{
|
|
name: "rule with an exclude_path that is not a regex",
|
|
settings: "rules:\n - level: error\n pattern: 'x'\n message: m\n exclude_path: '('\n",
|
|
want: "exclude_path",
|
|
},
|
|
}
|
|
|
|
for _, test := range tests {
|
|
t.Run(test.name, func(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
stage, err := diffRulesStage(t, test.settings)
|
|
if err == nil {
|
|
t.Fatalf("factory accepted unusable settings and built %q; want a refusal naming %q", stage.Name, test.want)
|
|
}
|
|
if !strings.Contains(err.Error(), test.want) {
|
|
t.Errorf("factory error = %v, want it to name %q", err, test.want)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
// TestDiffRulesStepAppliesRulesToTheCommittedDiff is the behaviour contract: the
|
|
// rules read the diff against the base branch, report the added lines they
|
|
// match with their new-file line numbers, park the run on an error-level
|
|
// finding, and leave a warn-level one advisory.
|
|
func TestDiffRulesStepAppliesRulesToTheCommittedDiff(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
panicRule := "rules:\n" +
|
|
" - id: no-new-panic\n" +
|
|
" level: error\n" +
|
|
" pattern: 'panic\\('\n" +
|
|
" message: new panic() call -- use error returns instead\n"
|
|
|
|
tests := []struct {
|
|
name string
|
|
settings string
|
|
diff string
|
|
wantParked bool
|
|
wantDetail []string
|
|
omitDetail []string
|
|
wantLog []string
|
|
omitLog []string
|
|
}{
|
|
{
|
|
name: "an error rule reports every added line it matches",
|
|
settings: panicRule,
|
|
diff: diffTwoFiles,
|
|
wantParked: true,
|
|
wantDetail: []string{
|
|
"main.go:3: new panic() call",
|
|
"main.go:23: new panic() call",
|
|
"notes.md:2: new panic() call",
|
|
"(no-new-panic)",
|
|
},
|
|
// The removed line is at old-file line 21 and the kept comment is at
|
|
// new-file line 4: neither is something this change added.
|
|
omitDetail: []string{"main.go:21", "main.go:4:", "notes.md:1"},
|
|
wantLog: []string{"rule_level=error", "file=main.go line=3", "rule=no-new-panic"},
|
|
},
|
|
{
|
|
name: "a warn rule is advisory",
|
|
settings: "rules:\n - id: advisory\n level: warn\n pattern: 'panic\\('\n message: consider error returns\n",
|
|
diff: diffTwoFiles,
|
|
wantParked: false,
|
|
wantLog: []string{"rule_level=warn", "file=main.go line=3", "consider error returns"},
|
|
},
|
|
{
|
|
name: "a rule that matches nothing is a no-op",
|
|
settings: "rules:\n - level: error\n pattern: 'this appears nowhere'\n message: unreachable\n",
|
|
diff: diffTwoFiles,
|
|
wantParked: false,
|
|
omitLog: []string{"unreachable"},
|
|
},
|
|
{
|
|
name: "context lines are not added lines",
|
|
settings: "rules:\n - level: error\n pattern: 'mentioned in a kept comment'\n message: kept comment matched\n",
|
|
diff: diffTwoFiles,
|
|
wantParked: false,
|
|
omitDetail: []string{"main.go:4"},
|
|
omitLog: []string{"kept comment matched"},
|
|
},
|
|
{
|
|
name: "a path scope keeps the rule off other files",
|
|
settings: "rules:\n - level: error\n pattern: 'panic\\('\n path: '\\.go$'\n message: go only\n",
|
|
diff: diffTwoFiles,
|
|
wantParked: true,
|
|
wantDetail: []string{"main.go:3", "go only"},
|
|
omitDetail: []string{"notes.md:2"},
|
|
},
|
|
{
|
|
name: "an exclude_path spares the files it names",
|
|
settings: "rules:\n - level: error\n pattern: 'panic\\('\n path: '\\.go$'\n exclude_path: '_test\\.go$'\n message: production code only\n",
|
|
diff: diffTestFile,
|
|
wantParked: false,
|
|
omitLog: []string{"production code only"},
|
|
},
|
|
{
|
|
name: "the same rule without the exclude_path matches the test file",
|
|
settings: "rules:\n - level: error\n pattern: 'panic\\('\n path: '\\.go$'\n message: any go file\n",
|
|
diff: diffTestFile,
|
|
wantParked: true,
|
|
wantDetail: []string{"main_test.go:2", "any go file"},
|
|
},
|
|
{
|
|
name: "no committed change is a no-op",
|
|
settings: panicRule,
|
|
diff: "",
|
|
wantParked: false,
|
|
omitLog: []string{"no-new-panic"},
|
|
},
|
|
}
|
|
|
|
for _, test := range tests {
|
|
t.Run(test.name, func(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
stage, err := diffRulesStage(t, test.settings)
|
|
if err != nil {
|
|
t.Fatalf("factory: %v", err)
|
|
}
|
|
var log bytes.Buffer
|
|
tc := diffRulesTaskContext(test.diff, &log)
|
|
|
|
if err := stage.Run(context.Background(), tc); err != nil {
|
|
t.Fatalf("stage.Run() = %v, want nil: a finding is a verdict about the task, not a stage failure", err)
|
|
}
|
|
|
|
detail := tc.Outcome.Detail
|
|
if test.wantParked {
|
|
if tc.Outcome.Status != StatusParked {
|
|
t.Fatalf("Outcome = %+v, want a parked outcome", tc.Outcome)
|
|
}
|
|
} else if tc.Outcome.Status != "" {
|
|
t.Errorf("Outcome = %+v, want no outcome: nothing the change did violated the rules", tc.Outcome)
|
|
}
|
|
for _, want := range test.wantDetail {
|
|
if !strings.Contains(detail, want) {
|
|
t.Errorf("park Detail = %q, want it to contain %q", detail, want)
|
|
}
|
|
}
|
|
for _, omit := range test.omitDetail {
|
|
if strings.Contains(detail, omit) {
|
|
t.Errorf("park Detail = %q, want it NOT to contain %q", detail, omit)
|
|
}
|
|
}
|
|
for _, want := range test.wantLog {
|
|
if !strings.Contains(log.String(), want) {
|
|
t.Errorf("log = %q, want it to contain %q", log.String(), want)
|
|
}
|
|
}
|
|
for _, omit := range test.omitLog {
|
|
if strings.Contains(log.String(), omit) {
|
|
t.Errorf("log = %q, want it NOT to contain %q", log.String(), omit)
|
|
}
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
// TestDiffRulesStepRequiresAPreparedWorktree pins the wiring failure a
|
|
// mis-ordered definition produces: a step placed before the workflow prepared a
|
|
// worktree has nothing to diff, and must say so instead of handing git an empty
|
|
// directory and parking with a git error.
|
|
func TestDiffRulesStepRequiresAPreparedWorktree(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
stage, err := diffRulesStage(t, "rules:\n - level: error\n pattern: 'x'\n message: m\n")
|
|
if err != nil {
|
|
t.Fatalf("factory: %v", err)
|
|
}
|
|
var log bytes.Buffer
|
|
tc := diffRulesTaskContext("", &log)
|
|
tc.Dir = ""
|
|
|
|
err = stage.Run(context.Background(), tc)
|
|
if err == nil {
|
|
t.Fatal("stage.Run() = nil with no worktree, want the wiring failure")
|
|
}
|
|
if !strings.Contains(err.Error(), "worktree") {
|
|
t.Errorf("stage.Run() error = %v, want it to name the missing worktree", err)
|
|
}
|
|
}
|
|
|
|
// TestDiffRulesStepPropagatesTheDiffFailure pins that a diff this stage could
|
|
// not read is an execution failure, not a clean change: reporting "no findings"
|
|
// because the read failed would pass a gate that never ran.
|
|
func TestDiffRulesStepPropagatesTheDiffFailure(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
stage, err := diffRulesStage(t, "rules:\n - level: error\n pattern: 'x'\n message: m\n")
|
|
if err != nil {
|
|
t.Fatalf("factory: %v", err)
|
|
}
|
|
var log bytes.Buffer
|
|
tc := diffRulesTaskContext("", &log)
|
|
tc.Trees = &fakeTrees{diffErr: errDiffUnavailable}
|
|
|
|
err = stage.Run(context.Background(), tc)
|
|
if err == nil {
|
|
t.Fatal("stage.Run() = nil when the diff could not be read, want the read failure")
|
|
}
|
|
if !strings.Contains(err.Error(), "diff") {
|
|
t.Errorf("stage.Run() error = %v, want it to name the diff it could not read", err)
|
|
}
|
|
if tc.Outcome.Status != "" {
|
|
t.Errorf("Outcome = %+v, want none: a read failure is not a verdict", tc.Outcome)
|
|
}
|
|
}
|
|
|
|
// TestAddedDiffLinesAttributesNewFilePositions drives the walker on its own,
|
|
// because the line a finding carries is the difference between an operator
|
|
// being able to find the violation and not.
|
|
func TestAddedDiffLinesAttributesNewFilePositions(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
tests := []struct {
|
|
name string
|
|
diff string
|
|
want []diffLine
|
|
}{
|
|
{
|
|
name: "one hunk",
|
|
diff: "diff --git a/a.go b/a.go\n--- a/a.go\n+++ b/a.go\n@@ -1,2 +1,3 @@\n package a\n+var b = 1\n var c = 2\n",
|
|
want: []diffLine{{Path: "a.go", Line: 2, Text: "var b = 1"}},
|
|
},
|
|
{
|
|
name: "a second hunk keeps counting from its own header",
|
|
diff: "diff --git a/a.go b/a.go\n--- a/a.go\n+++ b/a.go\n@@ -1,1 +1,2 @@\n package a\n+var b = 1\n@@ -40,1 +41,2 @@\n func f() {}\n+func g() {}\n",
|
|
want: []diffLine{{Path: "a.go", Line: 2, Text: "var b = 1"}, {Path: "a.go", Line: 42, Text: "func g() {}"}},
|
|
},
|
|
{
|
|
name: "a removed line advances no new-file position",
|
|
diff: "diff --git a/a.go b/a.go\n--- a/a.go\n+++ b/a.go\n@@ -1,3 +1,2 @@\n package a\n-var gone = 1\n+var kept = 2\n var tail = 3\n",
|
|
want: []diffLine{{Path: "a.go", Line: 2, Text: "var kept = 2"}},
|
|
},
|
|
{
|
|
name: "a header for the next file moves the path, not the position",
|
|
diff: "diff --git a/a.go b/a.go\n--- a/a.go\n+++ b/a.go\n@@ -1,1 +1,2 @@\n package a\n+var b = 1\ndiff --git a/b.go b/b.go\n--- a/b.go\n+++ b/b.go\n@@ -1,1 +1,2 @@\n package b\n+var c = 2\n",
|
|
want: []diffLine{{Path: "a.go", Line: 2, Text: "var b = 1"}, {Path: "b.go", Line: 2, Text: "var c = 2"}},
|
|
},
|
|
{
|
|
// A body line whose own text begins with the file-header marker is
|
|
// still a body line: inside a hunk, `+++ x` is the added line `++ x`.
|
|
name: "an added line that looks like a file header is body text",
|
|
diff: "diff --git a/a.md b/a.md\n--- a/a.md\n+++ b/a.md\n@@ -1,1 +1,2 @@\n # a\n+++ title\n",
|
|
want: []diffLine{{Path: "a.md", Line: 2, Text: "++ title"}},
|
|
},
|
|
{
|
|
name: "no newline marker is not a line",
|
|
diff: "diff --git a/a.go b/a.go\n--- a/a.go\n+++ b/a.go\n@@ -1,1 +1,2 @@\n package a\n+var b = 1\n\\ No newline at end of file\n",
|
|
want: []diffLine{{Path: "a.go", Line: 2, Text: "var b = 1"}},
|
|
},
|
|
{
|
|
name: "an empty diff adds nothing",
|
|
diff: "",
|
|
want: nil,
|
|
},
|
|
}
|
|
|
|
for _, test := range tests {
|
|
t.Run(test.name, func(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
got := addedDiffLines(test.diff)
|
|
if len(got) != len(test.want) {
|
|
t.Fatalf("addedDiffLines() = %+v, want %+v", got, test.want)
|
|
}
|
|
for i := range got {
|
|
if got[i] != test.want[i] {
|
|
t.Errorf("addedDiffLines()[%d] = %+v, want %+v", i, got[i], test.want[i])
|
|
}
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
// diffRulesTestTaskContext is the same context a diff-rules stage runs against,
|
|
// for a test that drives a real worktree instead of a fake one.
|
|
func diffRulesTestTaskContext(t *testing.T, dir string, log *bytes.Buffer) *TaskContext {
|
|
t.Helper()
|
|
tc := diffRulesTaskContext("", log)
|
|
tc.Dir = dir
|
|
return tc
|
|
}
|
|
|
|
// TestDiffRulesStepReadsARealDiff drives the step against the production Trees
|
|
// implementation rather than a fixture: every other test here feeds a
|
|
// hand-written unified diff, and the positions a rule reports have to survive
|
|
// what a real worktree actually emits -- headers, index lines and all.
|
|
func TestDiffRulesStepReadsARealDiff(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
dir := gitRepoWithOriginRef(t, "main")
|
|
added := "package main\n\nvar a = 1\n\nfunc boom() { panic(\"boom\") }\n"
|
|
if err := os.WriteFile(filepath.Join(dir, "main.go"), []byte(added), 0o644); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
runGit(t, dir, "add", "-A")
|
|
runGit(t, dir, "commit", "-m", "add panic")
|
|
|
|
stage, err := diffRulesStage(t, "rules:\n - id: no-new-panic\n level: error\n pattern: 'panic\\('\n message: new panic() call\n")
|
|
if err != nil {
|
|
t.Fatalf("factory: %v", err)
|
|
}
|
|
var log bytes.Buffer
|
|
tc := diffRulesTestTaskContext(t, dir, &log)
|
|
tc.Trees = &worktree.Manager{WorkDir: t.TempDir()}
|
|
|
|
if err := stage.Run(context.Background(), tc); err != nil {
|
|
t.Fatalf("stage.Run(): %v", err)
|
|
}
|
|
if tc.Outcome.Status != StatusParked {
|
|
t.Fatalf("Outcome = %+v, want a parked outcome for the added panic", tc.Outcome)
|
|
}
|
|
// The panic is on line 5 of the file the change produces. A walker that
|
|
// counted the diff's own offsets would report a different number.
|
|
if !strings.Contains(tc.Outcome.Detail, "main.go:5: new panic() call") {
|
|
t.Errorf("park Detail = %q, want it to locate the added line as main.go:5", tc.Outcome.Detail)
|
|
}
|
|
}
|