Engineering

Testing Strategy

Current Status

Use Go's standard test runner.

Baseline Expectations

  • Unit tests cover domain logic and pure transformations.
  • Integration tests cover persistence, API boundaries, queues, and external service adapters.
  • End-to-end tests cover critical user workflows once a UI or API surface exists.
  • Regression tests accompany meaningful bug fixes.

Commands

scripts/test-go-modules.sh
scripts/check-root-deps.sh
go test ./...
scripts/vulncheck-go-modules.sh
go build ./cmd/gowdk
node --check editors/vscode/extension.js
node --test editors/vscode/*.test.js
scripts/test-parser-fuzz.sh
scripts/test-generated-app-integration.sh
scripts/test-generated-output-determinism.sh
go build -o /tmp/gowdk-cli ./cmd/gowdk
rm -rf /tmp/gowdk-init && /tmp/gowdk-cli init /tmp/gowdk-init && (cd /tmp/gowdk-init && /tmp/gowdk-cli build)
go run ./cmd/gowdk build --out /tmp/gowdk-build examples/pages/home.page.gwdk examples/pages/hero.cmp.gwdk
test -f /tmp/gowdk-build/gowdk-routes.json
test -f /tmp/gowdk-build/gowdk-assets.json
test -f /tmp/gowdk-build/openapi.json
test -f /tmp/gowdk-build/asyncapi.json
go test ./cmd/gowdk

Use node --check and node --test editors/vscode/*.test.js when editor extension files change or before release-style verification.

Example commands run from the repository root use the root gowdk.config.go. Project-level compiler commands must have that file in the working directory or must pass --config <file>.

Verification Matrix

AreaCommandWhen
Go packagesscripts/test-go-modules.shEvery code change; includes the root module and nested optional adapter modules.
Root dependency surfacescripts/check-root-deps.shDependency-policy changes, CI, and release-style verification.
Root Go packagesgo test ./...Core compiler/runtime changes when optional adapter modules are not relevant.
Go vulnerability scanscripts/vulncheck-go-modules.shRelease-style checks and dependency changes.
CLI buildgo build ./cmd/gowdkCLI, compiler, runtime, addon, or release changes.
Go formattinggofmt -w <files>Changed Go files before handoff.
Parser fuzz smokescripts/test-parser-fuzz.shParser, tokenizer, syntax recovery, and diagnostic recovery changes.
Generated app integrationscripts/test-generated-app-integration.shGenerated binary, SSR, action, fragment, CSRF, and contract adapter changes.
Generated output determinismscripts/test-generated-output-determinism.shGenerated HTML, manifest, report, inspect, or route/sitemap output changes.
VS Code extension syntaxnode --check editors/vscode/extension.jsEditor extension changes and broad verification.
VS Code extension behaviornode --test editors/vscode/*.test.jsEditor extension pure helper changes and broad verification.
SPA/action examplesgo run ./cmd/gowdk check examples/pages/home.page.gwdk examples/actions/newsletter.page.gwdkLanguage/tooling changes.
Init project smokego build -o /tmp/gowdk-cli ./cmd/gowdk && rm -rf /tmp/gowdk-init && /tmp/gowdk-cli init /tmp/gowdk-init && (cd /tmp/gowdk-init && /tmp/gowdk-cli build)CLI scaffold changes.
SSR examplego run ./cmd/gowdk check --ssr examples/ssr/dashboard.page.gwdkSSR validation or example changes.
Manifest smokego run ./cmd/gowdk manifest --ssr examples/pages/*.gwdk examples/actions/*.gwdk examples/partials/*.gwdk examples/api/*.gwdk examples/ssr/*.gwdkManifest, parser, or CLI output changes.
SPA build smokego run ./cmd/gowdk build --out /tmp/gowdk-build examples/pages/home.page.gwdk examples/pages/hero.cmp.gwdk && test -f /tmp/gowdk-build/gowdk-routes.json && test -f /tmp/gowdk-build/gowdk-assets.json && test -f /tmp/gowdk-build/openapi.json && test -f /tmp/gowdk-build/asyncapi.jsonParser, view, buildgen, component, or CLI build changes.
Dev loop testsgo test ./cmd/gowdkDev mode changes.
Action redirect smokego run ./cmd/gowdk build --out /tmp/gowdk-action-build --app /tmp/gowdk-action-app --bin /tmp/gowdk-action-site examples/actions/signup.page.gwdkAction parsing or generated action endpoint changes.
Local serve testsgo test ./cmd/gowdkCLI serving or option parsing changes.
Generated app testsgo test ./cmd/gowdk ./internal/appgenGenerated embedded app or binary-serving changes.

Fuzz, Integration, And Determinism

  • scripts/test-parser-fuzz.sh is the explicit parser fuzz runner. It defaults to GOWDK_FUZZTIME=1s for CI smoke cost; use a longer local run such as GOWDK_FUZZTIME=30s scripts/test-parser-fuzz.sh before risky parser work.
  • scripts/test-generated-app-integration.sh is the generated-app integration slice. It builds temporary binaries through internal/appgen tests and exercises representative request-time flows.
  • scripts/test-generated-output-determinism.sh is the generated output and report determinism slice. It compares two clean builds plus manifest, sitemap, routes, and asset-graph report output.

Keep these as separate commands so CI can show whether a failure is fuzz input, runtime integration, or nondeterministic output.

Coverage Priorities

  1. Core domain behavior.
  2. Compiler diagnostics for render modes and addon requirements.
  3. Manifest generation and route normalization.
  4. Parser behavior for .gwdk syntax.
  5. SPA/prerender output and generated route handlers.
  6. Typed action decoding, validation, CSRF, redirects, and fragments.
  7. SSR addon routing, guards, server {}, layouts, and errors.

Existing Coverage

  • internal/compiler tests cover SSR addon enforcement, duplicate page/component/layout identities, layout reference resolution, dynamic SPA routes requiring paths, actions without SSR, and server {} rejection on SPA pages.
  • internal/discover tests cover recursive .gwdk include/exclude matching.
  • internal/parser tests cover page/component/layout metadata declarations, paths, build, load, view, props, act, captured paths/build/load/view bodies, the first action input/redirect body subset, and render mode rejection.
  • internal/viewrender tests cover view markup rendering, escaping, expression attributes, shorthand class/id normalization, component expansion, and missing component/prop errors.
  • internal/buildgen tests cover app-shell HTML emission, literal build data, imported Go build data functions, build-data route-param binding, literal dynamic paths, route and asset manifest output, component expansion, nested route output paths, and no partial output on unsupported pages.
  • internal/lang tests cover lexical tokenization, diagnostics, formatting, file checks, and manifest JSON from parsed source files.
  • internal/lang tests cover site-map JSON for movable page files.
  • internal/lang golden tests cover the IR-derived manifest JSON render/path/guard/action output.
  • internal/compiler tests cover route metadata for SPA/SSR routes, endpoint metadata for actions/APIs, and missing SSR addon rejection.
  • internal/clientrt tests cover the embedded framework browser runtime source files, render the placeholder templates, require Node for the client expression conformance test against internal/clientlang, run node --check for those .js files when node is available, and run a dependency-free Node DOM harness for innerHTML and outerHTML swaps.
  • internal/lsp tests cover initialize, diagnostics, formatting, completion, hover, component and open-Go go-to-definition, references, semantic tokens, code actions, shutdown, and exit protocol behavior.
  • editors/vscode tests cover extension route hierarchy helpers.
  • cmd/gowdk tests cover build --out writing index.html, expanding a component file, discovering build inputs when explicit paths are omitted, loading literal build config for source/output settings, configured build targets, selected target builds, and local generated-output serving behavior.
  • cmd/gowdk tests cover dev option parsing, invalid dev intervals, content-hash input snapshots, snapshot diffs, no-op touch detection, incremental SPA page rebuild selection, and component-change fallback.
  • cmd/gowdk and internal/appgen tests cover generated embedded app source, binary compilation, WASM artifact compilation, live binary HTTP serving, and first-slice action redirect routing.
  • Update the generated app golden with go test ./internal/appgen -run TestGeneratedGoMatchesGoldenFixture -update when an intentional generated Go change lands.
  • internal/buildgen and internal/appgen tests cover preserving unchanged generated file modification times so local dev loops do not retrigger on identical output.
  • internal/buildgen tests cover incremental changed-page rendering, complete route manifest refreshes, and stale route output cleanup.
  • internal/project tests cover literal gowdk.config.go parsing for source discovery, module source groups, build output, and build targets.
  • Nested optional adapter modules cover Chi, Echo, Fiber, Gin, Redis Streams, NATS, and WebSocket integration packages without adding those third-party dependencies to the root module graph.
  • internal/parser/fuzz_test.go defines FuzzParseSyntax with page, component, layout, endpoint, and broken-source seeds.
  • scripts/test-generated-output-determinism.sh compares generated HTML, route/asset manifests, OpenAPI/AsyncAPI, build reports, and public report command output across two clean runs.