Skip to content

Commit db30841

Browse files
authored
Merge pull request #1463 from k1LoW/fix/include-force-option
fix: pass includeConfig.force to newNestedOperator
2 parents 20f49b2 + 1f73ad3 commit db30841

5 files changed

Lines changed: 73 additions & 2 deletions

File tree

‎force_test.go‎

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,48 @@ func TestForceRun(t *testing.T) {
3030
})
3131
}
3232
}
33+
34+
func TestIncludeForceRun(t *testing.T) {
35+
tests := []struct {
36+
book string
37+
}{
38+
{"testdata/book/force_include.yml"},
39+
{"testdata/book/inline_include_with_force.yml"},
40+
}
41+
for _, tt := range tests {
42+
t.Run(tt.book, func(t *testing.T) {
43+
ctx := context.Background()
44+
o, err := New(Book(tt.book))
45+
if err != nil {
46+
t.Fatal(err)
47+
}
48+
if err := o.Run(ctx); err == nil {
49+
t.Fatal("expected error")
50+
}
51+
r := o.Result()
52+
if len(r.StepResults) == 0 {
53+
t.Fatal("expected step results")
54+
}
55+
foundIncludedRunResults := false
56+
for _, sr := range r.StepResults {
57+
if len(sr.IncludedRunResults) == 0 {
58+
continue
59+
}
60+
foundIncludedRunResults = true
61+
for j, irr := range sr.IncludedRunResults {
62+
if len(irr.StepResults) == 0 {
63+
t.Fatalf("included run[%d]: expected step results", j)
64+
}
65+
for i, isr := range irr.StepResults {
66+
if isr.Skipped {
67+
t.Errorf("included step[%d]: got skipped=%v, want skipped=false", i, isr.Skipped)
68+
}
69+
}
70+
}
71+
}
72+
if !foundIncludedRunResults {
73+
t.Fatal("expected included run results")
74+
}
75+
})
76+
}
77+
}

‎include.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ func (rnr *includeRunner) Run(ctx context.Context, s *step) error {
128128

129129
var oo *operator
130130
if c.inline {
131-
oo, err = o.newNestedOperator(c.step, bookFromInlineWithStore(c, o.bookPath, pstore), SkipTest(c.skipTest))
131+
oo, err = o.newNestedOperator(c.step, bookFromInlineWithStore(c, o.bookPath, pstore), SkipTest(c.skipTest), Force(c.force))
132132
if err != nil {
133133
return err
134134
}
@@ -143,7 +143,7 @@ func (rnr *includeRunner) Run(ctx context.Context, s *step) error {
143143
return err
144144
}
145145

146-
oo, err = o.newNestedOperator(c.step, bookWithStore(ipath, pstore), SkipTest(c.skipTest))
146+
oo, err = o.newNestedOperator(c.step, bookWithStore(ipath, pstore), SkipTest(c.skipTest), Force(c.force))
147147
if err != nil {
148148
return err
149149
}

‎testdata/book/force_include.yml‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
desc: Include with force option
2+
steps:
3+
a:
4+
include:
5+
path: force_included.yml
6+
force: true

‎testdata/book/force_included.yml‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
desc: Included runbook with failing step
2+
steps:
3+
-
4+
test: true
5+
-
6+
test: false
7+
-
8+
test: true
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
desc: Inline include with force option
2+
steps:
3+
a:
4+
include:
5+
force: true
6+
steps:
7+
-
8+
test: true
9+
-
10+
test: false
11+
-
12+
test: true

0 commit comments

Comments
 (0)
⌂ 换网址