Skip to content
Merged
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
2 changes: 1 addition & 1 deletion construct_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ func TestConstruct(t *testing.T) {
}

if !slices.Equal([]testoplugin.Option{
{Value: "fizz"},
{Value: "foo", Propagate: true},
{Value: "fizz"},
}, child.MockPluginWithoutT.options) {
t.Error("child.MockPluginWithoutT.options not equal to expected")
}
Expand Down
19 changes: 17 additions & 2 deletions t.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,20 +359,35 @@ func (t *T) markFailure(kind testoreflect.TestFailureKind) {
}

func (t *T) options() []testoplugin.Option {
options := t.levelOptions
size := len(t.levelOptions)
byLevel := [][]testoplugin.Option{t.levelOptions}

parent := t.parent

for parent != nil {
level := make([]testoplugin.Option, 0, len(parent.levelOptions))

for _, o := range parent.levelOptions {
if o.Propagate {
options = append(options, o)
level = append(level, o)
}
}

byLevel = append(byLevel, level)

size += len(level)

parent = parent.parent
}

options := make([]testoplugin.Option, 0, size)

// so that child options come after parent options

for _, level := range slices.Backward(byLevel) {
options = append(options, level...)
}

return options
}

Expand Down
Loading