File tree Expand file tree Collapse file tree 2 files changed +29
-2
lines changed Expand file tree Collapse file tree 2 files changed +29
-2
lines changed Original file line number Diff line number Diff line change @@ -185,16 +185,22 @@ func (m MultiStageExpr) reorderStages() []StageExpr {
185
185
func combineFilters (in []* LineFilterExpr ) StageExpr {
186
186
result := in [len (in )- 1 ]
187
187
for i := len (in ) - 2 ; i >= 0 ; i -- {
188
- leafNode (result ).Left = in [i ]
188
+ leaf := leafNode (result , in [i ])
189
+ if leaf != nil {
190
+ leaf .Left = in [i ]
191
+ }
189
192
}
190
193
191
194
return result
192
195
}
193
196
194
- func leafNode (in * LineFilterExpr ) * LineFilterExpr {
197
+ func leafNode (in * LineFilterExpr , child * LineFilterExpr ) * LineFilterExpr {
195
198
current := in
196
199
//nolint:revive
197
200
for ; current .Left != nil ; current = current .Left {
201
+ if current == child || current .Left == child {
202
+ return nil
203
+ }
198
204
}
199
205
return current
200
206
}
Original file line number Diff line number Diff line change @@ -1093,3 +1093,24 @@ func TestGroupingString(t *testing.T) {
1093
1093
}
1094
1094
require .Equal (t , " without ()" , g .String ())
1095
1095
}
1096
+
1097
+ func TestCombineFilters (t * testing.T ) {
1098
+ in := []* LineFilterExpr {
1099
+ {LineFilter : LineFilter {Ty : log .LineMatchEqual , Match : "test1" }},
1100
+ {LineFilter : LineFilter {Ty : log .LineMatchEqual , Match : "test2" }},
1101
+ }
1102
+
1103
+ var combineFilter StageExpr
1104
+ for i := 0 ; i < 2 ; i ++ {
1105
+ combineFilter = combineFilters (in )
1106
+ }
1107
+
1108
+ current := combineFilter .(* LineFilterExpr )
1109
+ i := 0
1110
+ for ; current .Left != nil ; current = current .Left {
1111
+ i ++
1112
+ if i > 2 {
1113
+ t .Fatalf ("left num isn't a correct number" )
1114
+ }
1115
+ }
1116
+ }
You can’t perform that action at this time.
0 commit comments