diff --git a/construct_test.go b/construct_test.go index 01a2f0b..12fcc93 100644 --- a/construct_test.go +++ b/construct_test.go @@ -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") } diff --git a/t.go b/t.go index 189770d..5f45799 100644 --- a/t.go +++ b/t.go @@ -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 }