From d513ab01a5b71834a73ba7a8b92830ada88faa66 Mon Sep 17 00:00:00 2001 From: metafates Date: Mon, 1 Jun 2026 22:44:29 +0300 Subject: [PATCH 1/3] add priority for plans and overrides --- CHANGELOG.md | 10 ++++++++++ plugin.go | 8 ++++++++ runner.go | 2 ++ testoplugin/overrides.go | 4 ++++ testoplugin/plan.go | 4 ++++ testoplugin/plugin.go | 6 +++--- 6 files changed, 31 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0435cb4..fcf1f56 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 priority for plugin plans and overrides. + +### Fixed + +- Add missing call to `t.Helper` in runner. + ## [1.3.2] - 2026-05-30 ### Fixed diff --git a/plugin.go b/plugin.go index 2f666f7..ba02540 100644 --- a/plugin.go +++ b/plugin.go @@ -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() @@ -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, diff --git a/runner.go b/runner.go index eb598bf..eff605f 100644 --- a/runner.go +++ b/runner.go @@ -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, diff --git a/testoplugin/overrides.go b/testoplugin/overrides.go index 04b365d..42ba39f 100644 --- a/testoplugin/overrides.go +++ b/testoplugin/overrides.go @@ -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] diff --git a/testoplugin/plan.go b/testoplugin/plan.go index b994964..6107588 100644 --- a/testoplugin/plan.go +++ b/testoplugin/plan.go @@ -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. // diff --git a/testoplugin/plugin.go b/testoplugin/plugin.go index e66fc9c..4eea681 100644 --- a/testoplugin/plugin.go +++ b/testoplugin/plugin.go @@ -15,10 +15,10 @@ 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. type Priority int const ( From 00fc301f0dddd675b5d1e0fb0b0426033bc498c6 Mon Sep 17 00:00:00 2001 From: metafates Date: Sun, 7 Jun 2026 12:46:05 +0300 Subject: [PATCH 2/3] update priority comment --- testoplugin/plugin.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/testoplugin/plugin.go b/testoplugin/plugin.go index 4eea681..e391ad8 100644 --- a/testoplugin/plugin.go +++ b/testoplugin/plugin.go @@ -19,6 +19,8 @@ import "math" // invoked when other parts are available. // // "Plugin component" means plan, hook, override, etc. +// +// See [TryFirst] and [TryLast] for predefined priority values. type Priority int const ( From f712c3cf69299a136b9449fa609f8e250536fb36 Mon Sep 17 00:00:00 2001 From: metafates Date: Sun, 7 Jun 2026 12:55:19 +0300 Subject: [PATCH 3/3] update CHANGELOG --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fcf1f56..45b07d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -- Support priority for plugin plans and overrides. +- Support for setting plugin priority (order) for `Plan` and `Overrides` components. ### Fixed