[object Object]

← back to Cli Printing Press

test(cli): speed up generator test suite (#323)

f9c9efd4eb69d780f287913c15e7d1d77a7fdeb4 · 2026-04-26 19:36:09 -0700 · Trevin Chow

Files touched

Diff

commit f9c9efd4eb69d780f287913c15e7d1d77a7fdeb4
Author: Trevin Chow <trevin@trevinchow.com>
Date:   Sun Apr 26 19:36:09 2026 -0700

    test(cli): speed up generator test suite (#323)
---
 .gitignore                           |  1 +
 internal/generator/generator_test.go | 20 +++++++++++++++-----
 2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/.gitignore b/.gitignore
index 21f7232f..12b35319 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,6 +3,7 @@
 .gotmp/
 .claude/worktrees/
 /refactor/artifacts/
+/tests/artifacts/perf/
 /printing-press
 library/
 dist/
diff --git a/internal/generator/generator_test.go b/internal/generator/generator_test.go
index 9fc73322..29e9c2ad 100644
--- a/internal/generator/generator_test.go
+++ b/internal/generator/generator_test.go
@@ -523,6 +523,15 @@ func countFiles(t *testing.T, root string) int {
 func runGoCommand(t *testing.T, dir string, args ...string) {
 	t.Helper()
 
+	// Generated-project compile tests exercise module resolution via -mod=mod;
+	// production Validate still owns the go mod tidy quality gate.
+	if len(args) >= 2 && args[0] == "mod" && args[1] == "tidy" {
+		return
+	}
+	if len(args) > 0 && (args[0] == "build" || args[0] == "test") {
+		args = append([]string{args[0], "-mod=mod"}, args[1:]...)
+	}
+
 	cmd := exec.Command("go", args...)
 	cmd.Dir = dir
 	cacheDir, err := goBuildCacheDir(dir)
@@ -614,9 +623,8 @@ func TestGenerateBrowserChromeTransport(t *testing.T) {
 	readme, err := os.ReadFile(filepath.Join(outputDir, "README.md"))
 	require.NoError(t, err)
 	assert.Contains(t, string(readme), "Chrome-compatible HTTP transport")
-
-	runGoCommand(t, outputDir, "mod", "tidy")
-	runGoCommand(t, outputDir, "build", "./...")
+	// The H3 sibling below compiles the same surf-backed client path; this
+	// test stays focused on the non-H3 rendering branch.
 }
 
 func TestGenerateBrowserChromeH3Transport(t *testing.T) {
@@ -656,7 +664,7 @@ func TestGenerateBrowserChromeH3Transport(t *testing.T) {
 	assert.Contains(t, string(clientGo), "ForceHTTP3()")
 
 	runGoCommand(t, outputDir, "mod", "tidy")
-	runGoCommand(t, outputDir, "build", "./...")
+	runGoCommand(t, outputDir, "test", "./internal/client")
 }
 
 func TestGenerateHTMLExtractionEndpoint(t *testing.T) {
@@ -2656,7 +2664,9 @@ func TestGenerateGraphQLBFFUsesSemanticCommandSurface(t *testing.T) {
 	}
 	apiSpec, err := browsersniff.AnalyzeCapture(capture)
 	require.NoError(t, err)
-	apiSpec.HTTPTransport = spec.HTTPTransportBrowserChromeH3
+	// Browser/H3 transport has focused coverage above; this test is about
+	// GraphQL BFF command shape, so keep its generated compile path lean.
+	apiSpec.HTTPTransport = spec.HTTPTransportStandard
 	apiSpec.Auth = spec.AuthConfig{Type: "none"}
 	apiSpec.Config = spec.ConfigSpec{Format: "toml", Path: "~/.config/example-pp-cli/config.toml"}
 

← b1001491 refactor(cli): split verify command helpers (#322)  ·  back to Cli Printing Press  ·  docs(cli): use go fmt ./... for formatting instructions (#32 9b97201f →