e2egate

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 7, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package e2egate parses `go test -json` event streams and decides whether the run satisfies the e2e execution gate: at least one test must have actually executed (passed or failed), and no package may declare tests yet have all of them skipped — that pattern indicates require.Docker / PG / RMQ gates were not opened, producing a misleading green CI.

The parser is invoked from the command line as a stdin pipe consumer:

go test -tags=e2e -json ./tests/e2e/... | tee /tmp/e2e.json | e2egate

On gate failure, exit code 1 with reasons on stderr. On success, exit 0 with empty stdout/stderr. The pipeline-friendly tee preserves the raw event stream for log archival.

ref: cmd/internal/test2json — event schema (Action, Package, Test, Output, Elapsed)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PackageStat

type PackageStat struct {
	// Executed counts pass + fail tests.
	Executed int
	// Skipped counts skipped tests.
	Skipped int
	// BuildFailed is true when the package emitted a build failure (no
	// test events; package-level "fail" action with build-failed output).
	BuildFailed bool
	// Action is the package-level terminal action ("pass", "fail", "skip").
	Action string
}

PackageStat tracks per-package test counters and the terminal action emitted for the package event (Test == "").

type Result

type Result struct {
	// TotalExecuted is the count of test-level events that terminated with
	// pass or fail (i.e., the test actually ran a body).
	TotalExecuted int
	// TotalSkipped is the count of test-level events that terminated with
	// skip (including conditional t.Skip).
	TotalSkipped int
	// Packages keyed by import path; each tracks per-package counters.
	Packages map[string]*PackageStat
	// Reasons holds gate-failure messages (one per triggered rule); empty
	// when the gate passes.
	Reasons []string
}

Result is the aggregated outcome of a `go test -json` run.

func Parse

func Parse(r io.Reader) (Result, error)

Parse reads `go test -json` events from r and returns the aggregated Result. Parse returns an error only on I/O failures or malformed JSON; gate-failure conditions are reported via Result.Failed() / Result.Reasons.

func (Result) Failed

func (r Result) Failed() bool

Failed reports whether the gate fails. The gate fails when at least one rule in Reasons triggered.

Directories

Path Synopsis
cmd
e2egate command
Command e2egate is a stdin-based gate over `go test -json` event streams.
Command e2egate is a stdin-based gate over `go test -json` event streams.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL