Documentation
¶
Index ¶
- func RunAllTests(t *testing.T, rootDir string)
- func RunAllTestsWithRunners(t *testing.T, rootDir string, runners []VersionRunner)
- type AmpelBinaries
- type BinaryRunner
- func (b *BinaryRunner) EngineVersion() string
- func (b *BinaryRunner) RunTest(ctx context.Context, baseDir string, tc *tester.TestCase) (*tester.TestResult, error)
- func (b *BinaryRunner) SupportsCollectors(context.Context) bool
- func (b *BinaryRunner) SupportsRuntimeRequirements(ctx context.Context) bool
- func (b *BinaryRunner) Version() string
- type DiscoveredSuite
- type HeadRunner
- func (h *HeadRunner) EngineVersion() string
- func (h *HeadRunner) RunTest(ctx context.Context, baseDir string, tc *tester.TestCase) (*tester.TestResult, error)
- func (h *HeadRunner) SupportsCollectors(context.Context) bool
- func (h *HeadRunner) SupportsRuntimeRequirements(context.Context) bool
- func (h *HeadRunner) Version() string
- type VersionRunner
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RunAllTests ¶
RunAllTests discovers test suites under rootDir and runs each test case as a Go subtest against HEAD (library), stable, and eol (downloaded or built from the two most recent upstream tags).
func RunAllTestsWithRunners ¶
func RunAllTestsWithRunners(t *testing.T, rootDir string, runners []VersionRunner)
RunAllTestsWithRunners discovers suites and runs them against the provided version runners.
Types ¶
type AmpelBinaries ¶
type AmpelBinaries struct {
// Stable is the binary for the latest stable tag.
Stable string
// StableTag is the tag used for the stable binary.
StableTag string
// EOL is the binary for the second-latest stable tag.
EOL string
// EOLTag is the tag used for the eol binary.
EOLTag string
// contains filtered or unexported fields
}
AmpelBinaries holds the paths to ampel binaries for specific versions.
func GetAmpelBinaries ¶
func GetAmpelBinaries() (*AmpelBinaries, error)
GetAmpelBinaries fetches ampel binaries for the two most recent stable tags. It downloads pre-built binaries from GitHub releases. If that fails, it falls back to cloning and building from source.
func (*AmpelBinaries) Cleanup ¶
func (b *AmpelBinaries) Cleanup()
Cleanup removes the temporary directory with the binaries.
type BinaryRunner ¶
type BinaryRunner struct {
// Name is the version label shown in test output (e.g. "stable", "eol").
Name string
// Tag is the ampel release tag the binary was built from (e.g. "v1.3.7").
// It is the engine version compared against a test case's ampel-version
// floor. Leave empty when unknown; the runner then runs every test.
Tag string
// BinaryPath is the path to the ampel binary to invoke.
BinaryPath string
// contains filtered or unexported fields
}
BinaryRunner shells out to an ampel binary for verification. This avoids Go module dependency conflicts when testing against older ampel versions.
func (*BinaryRunner) EngineVersion ¶
func (b *BinaryRunner) EngineVersion() string
EngineVersion returns the release tag the binary was built from.
func (*BinaryRunner) RunTest ¶
func (b *BinaryRunner) RunTest(ctx context.Context, baseDir string, tc *tester.TestCase) (*tester.TestResult, error)
func (*BinaryRunner) SupportsCollectors ¶
func (b *BinaryRunner) SupportsCollectors(context.Context) bool
SupportsCollectors reports whether this ampel binary can run collector-based tests. Such tests need the binary's collector to synthesize the evidence (e.g. build a signature attestation from a sigstore bundle or a detached certificate + signature pair), and a binary whose collector predates that support silently returns no attestations, which surfaces as a spurious failure rather than a skip.
Unlike plugin requirements, that capability has no CLI signal to probe (the --collector and --signer flags long predate it), so released binaries are gated out and collector-based tests run against HEAD only. Once binaries advertise the capability, probe for it here instead of returning false.
func (*BinaryRunner) SupportsRuntimeRequirements ¶
func (b *BinaryRunner) SupportsRuntimeRequirements(ctx context.Context) bool
SupportsRuntimeRequirements probes (once) whether the binary advertises the --skip-unsupported-runtime verify flag. Presence of that flag is our signal that this ampel version understands policy runtime/plugin requirements and will skip rather than choke on a policy whose plugins it lacks. Older binaries that predate the flag return false.
func (*BinaryRunner) Version ¶
func (b *BinaryRunner) Version() string
type DiscoveredSuite ¶
type DiscoveredSuite struct {
Dir string // directory containing the config file
Suite *tester.TestSuite // parsed config
}
DiscoveredSuite is a test suite found during discovery.
func Discover ¶
func Discover(rootDir string) ([]DiscoveredSuite, error)
Discover walks rootDir looking for .ptests.yaml files and returns the parsed suites.
type HeadRunner ¶
type HeadRunner struct {
// contains filtered or unexported fields
}
HeadRunner uses the current (HEAD) ampel version via the Go library.
func (*HeadRunner) EngineVersion ¶
func (h *HeadRunner) EngineVersion() string
EngineVersion returns the version of the ampel module linked into the test binary as recorded in its build info: a release tag such as "v1.3.6", or a pseudo-version for an untagged commit. It returns "" when there is no build info or the module isn't linked, and "(devel)" when a replace directive points at a local checkout. TestCase.RunsOn treats both as unknown, so version-floored tests still run against them.
func (*HeadRunner) RunTest ¶
func (h *HeadRunner) RunTest(ctx context.Context, baseDir string, tc *tester.TestCase) (*tester.TestResult, error)
func (*HeadRunner) SupportsCollectors ¶
func (h *HeadRunner) SupportsCollectors(context.Context) bool
SupportsCollectors is always true for HEAD: the library under test is the current development tree, which carries the collector features the tests in this repository target.
func (*HeadRunner) SupportsRuntimeRequirements ¶
func (h *HeadRunner) SupportsRuntimeRequirements(context.Context) bool
SupportsRuntimeRequirements is always true for HEAD: the library under test is the current development tree, which carries every plugin the policies in this repository target.
func (*HeadRunner) Version ¶
func (h *HeadRunner) Version() string
type VersionRunner ¶
type VersionRunner interface {
Version() string
RunTest(ctx context.Context, baseDir string, tc *tester.TestCase) (*tester.TestResult, error)
// EngineVersion returns the semantic version of the ampel engine this
// runner executes (e.g. "v1.3.7"), or "" when it can't be determined.
// It is compared against a test case's ampel-version floor: tests that
// need a newer engine are skipped on this runner. An unknown version
// runs every test.
EngineVersion() string
// SupportsRuntimeRequirements reports whether this ampel understands policy
// runtime/plugin requirements, i.e. it will run a policy that declares them
// (when it has the plugin) or gracefully skip it (when it doesn't) rather
// than fail with an undefined-function error. Tests whose policy declares
// plugin requirements are skipped on runners that return false.
SupportsRuntimeRequirements(ctx context.Context) bool
// SupportsCollectors reports whether this runner can execute test cases that
// declare `collectors:` — i.e. whether it can synthesize evidence (such as
// signature attestations built from sigstore bundles or detached
// signatures) by running a collector. Tests that declare collectors are
// skipped on runners that return false.
SupportsCollectors(ctx context.Context) bool
}
VersionRunner can execute a test case against a specific ampel version.