diff --git a/.github/workflows/qa.yml b/.github/workflows/qa.yml index 12ba5ef..25ab9e5 100644 --- a/.github/workflows/qa.yml +++ b/.github/workflows/qa.yml @@ -6,6 +6,11 @@ name: Quality Assurance branches: - main pull_request: + types: + - opened + - synchronize + - reopened + - ready_for_review # Cancel prior runs on the same branch when a new one starts concurrency: diff --git a/CHANGELOG.md b/CHANGELOG.md index c3acbce..5a0e3df 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 + +### Changed + +- `testo.Options` now returns an empty struct to enable `var _ = testo.Options(...)` usage. + ## [1.2.0] - 2026-05-21 ### Added diff --git a/docs/how-to.md b/docs/how-to.md index 68bf921..3234e2c 100644 --- a/docs/how-to.md +++ b/docs/how-to.md @@ -76,12 +76,10 @@ func Test(t *testing.T) { Using `testo.Options`: ```go -func init() { - testo.Options( - myplugin.SomeOption(), - otherplugin.OtherOption(42), - ) -} +var _ = testo.Options( + myplugin.SomeOption(), + otherplugin.OtherOption(42), +) func Test(t *testing.T) { // options are automatically passed to these RunSuite calls. diff --git a/options.go b/options.go index 359a1c9..18690e9 100644 --- a/options.go +++ b/options.go @@ -21,11 +21,19 @@ var ( // func init() { // testo.Options(myplugin.OutputDir("...")) // } -func Options(options ...testoplugin.Option) { +// +// It returns an empty struct to enable the following usage: +// +// var _ = testo.Options(...) +// +// This is similar to [For] and slightly more concise than using init. +func Options(options ...testoplugin.Option) struct{} { globalOptionsMutex.Lock() defer globalOptionsMutex.Unlock() globalOptions = append(globalOptions, options...) + + return struct{}{} } func getOptions() []testoplugin.Option {