From 47d69cb998a447eea662ad1075f9d002dd875443 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Mon, 27 Apr 2026 09:18:52 +0300 Subject: Add context.Context to I/O-bound public APIs (generator.Run, processor.Run, atom.Generate, syncOutput) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - generator.Run(ctx, cfg) – ctx passed through to atom.Generate - processor.Run(ctx, cfg) – signature updated for cancellation propagation - atom.Generate(ctx, posts, cfg) – accepts ctx for future cancellation - syncOutput(ctx, cfg) – rsync subprocesses now use exec.CommandContext - Updated all call sites in tests, cmd/snonux/main.go, and integration tests - All call sites pass context.Background() / context.TODO() All tests pass: go test ./... --- integrationtests/integration_test.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'integrationtests') diff --git a/integrationtests/integration_test.go b/integrationtests/integration_test.go index 9beaf29..e3737f4 100644 --- a/integrationtests/integration_test.go +++ b/integrationtests/integration_test.go @@ -4,6 +4,7 @@ package integrationtests import ( + "context" "encoding/json" "encoding/xml" "fmt" @@ -23,6 +24,8 @@ import ( "codeberg.org/snonux/snonux/internal/processor" ) +var ctx = context.Background() //nolint:gochecknoglobals // test-only top-level helper used by every test in the file + // runPipeline executes both pipeline stages and returns the config used. func runPipeline(t *testing.T, inputDir, outputDir string) *config.Config { t.Helper() @@ -34,12 +37,12 @@ func runPipeline(t *testing.T, inputDir, outputDir string) *config.Config { Theme: "neon", } - _, err := processor.Run(cfg) + _, err := processor.Run(ctx, cfg) if err != nil { t.Fatalf("processor.Run: %v", err) } - if err := generator.Run(cfg); err != nil { + if err := generator.Run(ctx, cfg); err != nil { t.Fatalf("generator.Run: %v", err) } @@ -427,10 +430,10 @@ func TestThemeSelection(t *testing.T) { Theme: theme, } - if _, err := processor.Run(cfg); err != nil { + if _, err := processor.Run(ctx, cfg); err != nil { t.Fatalf("processor.Run: %v", err) } - if err := generator.Run(cfg); err != nil { + if err := generator.Run(ctx, cfg); err != nil { t.Fatalf("generator.Run for theme %q: %v", theme, err) } -- cgit v1.2.3