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
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ All notable changes to this project are documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased

### Added

- Support for setting plugin priority (order) for `Plan` and `Overrides` components.

### Fixed

- Add missing call to `t.Helper` in runner.

## [1.3.2] - 2026-05-30

### Fixed
Expand Down
8 changes: 8 additions & 0 deletions plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ func mergeSpecs(tb testing.TB, plugins ...testoplugin.Spec) testoplugin.Spec {
func mergePlans(tb testing.TB, plans ...testoplugin.Plan) testoplugin.Plan {
tb.Helper()

slices.SortStableFunc(plans, func(a, b testoplugin.Plan) int {
return cmp.Compare(a.Priority, b.Priority)
})

return testoplugin.Plan{
Prepare: func(suite testoreflect.SuiteInfo, tests *[]testoplugin.PlannedTest) {
tb.Helper()
Expand Down Expand Up @@ -113,6 +117,10 @@ func mergeHooks(tb testing.TB, hooks ...testoplugin.Hooks) testoplugin.Hooks {

//nolint:funlen // splitting this into subfunctons would make it worse
func mergeOverrides(overrides ...testoplugin.Overrides) testoplugin.Overrides {
slices.SortStableFunc(overrides, func(a, b testoplugin.Overrides) int {
return cmp.Compare(a.Priority, b.Priority)
})

return testoplugin.Overrides{
Log: mergeOverride(
overrides,
Expand Down
2 changes: 2 additions & 0 deletions runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,8 @@ func (r *runner[Suite, T]) runSuiteTests(t T, s Suite, tests suiteTests[Suite, T

for _, test := range allTests {
testingT.Run(test.Name, func(testingT *testing.T) {
testingT.Helper()

innerT := construct(
testingT,
&t,
Expand Down
4 changes: 4 additions & 0 deletions testoplugin/overrides.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ import (
// There exists a certain hierarchy what method calls what underneath.
// For example, overriding Log will affect Error, Skip, Fatal and their printf equivalents.
type Overrides struct {
// Priority defines global priority for these overrides.
// Overrides with lower priority values are called first.
Priority Priority

Log Override[FuncLog]
Parallel Override[FuncParallel]
TempDir Override[FuncTempDir]
Expand Down
4 changes: 4 additions & 0 deletions testoplugin/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import (

// Plan for running the tests.
type Plan struct {
// Priority sets plan priority.
// Plans with lower priority value are executed first.
Priority Priority

// Prepare may filter or re-order planned tests in-place.
// Nil values are ignored.
//
Expand Down
8 changes: 5 additions & 3 deletions testoplugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ package testoplugin
import "math"

// Priority defines execution order (priority).
// It defines when a plugin part should be invoked when other parts are available.
// It defines when a plugin component should be
// invoked when other parts are available.
//
// "Plugin part" means plan, hook, override, etc.
// Right now, only [Hook]s are supported.
// "Plugin component" means plan, hook, override, etc.
//
// See [TryFirst] and [TryLast] for predefined priority values.
type Priority int

const (
Expand Down
Loading