From 52e994fac3f41cae7c4a0239a72969c2a9a9380c Mon Sep 17 00:00:00 2001 From: metafates Date: Sun, 4 Oct 2026 07:32:12 +0300 Subject: [PATCH 1/3] add testo.Plugins function to obtain installed plugins --- CHANGELOG.md | 6 ++++++ t.go | 54 ++++++++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 54 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6bebc8e..03e18fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ 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 + +- `testo.Plugins` function to get plugin instances of a given `T`. + ## [1.8.0] - 2026-08-30 ### Added diff --git a/t.go b/t.go index 2c5cfe4..c45a9e8 100644 --- a/t.go +++ b/t.go @@ -620,18 +620,60 @@ func (t *T) logPlugins() { func Reflect(t CommonT) testoreflect.Reflection { t.Helper() - internal := t.unwrap() + u := t.unwrap() - info := internal.reflection.Load() + info := u.reflection.Load() - info.FailureSource = internal.failureSource.Load() - info.FailureKind = internal.failureKind.Load() - info.HasFatalSubtest = internal.hasFatalSubtest.Load() - info.TestingT = internal.testingT + info.FailureSource = u.failureSource.Load() + info.FailureKind = u.failureKind.Load() + info.HasFatalSubtest = u.hasFatalSubtest.Load() + info.TestingT = u.testingT return info } +// Plugins returns information about installed plugins +// in the given t instance. +// +// Returned slice follows plugins declaration order. +// +// For example: +// +// type T struct{ +// *testo.T +// *PluginBar +// *PluginFoo +// *PluginAllure +// } +// +// func (*Suite) Test(t T) { +// testo.Plugins(t) +// } +// +// Would return: +// +// []testoplugin.Plugin{*PluginBar(...), *PluginFoo(...), *PluginAllure(...)} +// +// NOTE: this function returns pointers to an actual plugin instances, so calling +// their methods is equivalent to calling T's methods. +func Plugins(t CommonT) []testoplugin.Plugin { + t.Helper() + + u := t.unwrap() + + plugins := make([]testoplugin.Plugin, 0, len(u.plugins)) + + for _, typ := range u.pluginOrder { + if typ == reflect.TypeFor[*T]() { + continue + } + + plugins = append(plugins, u.plugins[typ]) + } + + return plugins +} + type atomicInt[T ~int | ~int8 | ~int32 | ~int64] atomic.Int64 func (a *atomicInt[T]) Load() T { From a8855fe1eddf6a53540e349a0da12f16e8552b7d Mon Sep 17 00:00:00 2001 From: metafates Date: Wed, 21 Oct 2026 17:31:02 +0300 Subject: [PATCH 2/3] set plugins capacity as u.plugins-1 --- t.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t.go b/t.go index c45a9e8..686b596 100644 --- a/t.go +++ b/t.go @@ -661,7 +661,7 @@ func Plugins(t CommonT) []testoplugin.Plugin { u := t.unwrap() - plugins := make([]testoplugin.Plugin, 0, len(u.plugins)) + plugins := make([]testoplugin.Plugin, 0, max(0, len(u.plugins)-1)) for _, typ := range u.pluginOrder { if typ == reflect.TypeFor[*T]() { From 4440470d0751d0f040e706e658be6384ac5d3a85 Mon Sep 17 00:00:00 2001 From: metafates Date: Thu, 22 Oct 2026 12:21:27 +0300 Subject: [PATCH 3/3] update golangci-lint version --- .github/workflows/qa.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/qa.yml b/.github/workflows/qa.yml index f1a794e..9135779 100644 --- a/.github/workflows/qa.yml +++ b/.github/workflows/qa.yml @@ -77,7 +77,7 @@ jobs: - name: Run linters uses: golangci/golangci-lint-action@v9 with: - version: v2.13.2 + version: v2.15.0 args: --tests=false --timeout=5m update-coverage: