bazel_testing

package
v0.18.8 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2019 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package bazel_testing provides an integration testing framework for testing rules_go with Bazel.

Tests may be written by declaring a go_bazel_test target instead of a go_test (go_bazel_test is defined in def.bzl here), then calling TestMain. Tests are run in a synthetic test workspace. Tests may run bazel commands with RunBazel.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunBazel

func RunBazel(args ...string) error

RunBazel invokes a bazel command with a list of arguments.

If the command starts but exits with a non-zero status, a *StderrExitError will be returned which wraps the original *exec.ExitError.

func TestMain

func TestMain(m *testing.M, args Args)

TestMain should be called by tests using this framework from a function named "TestMain". For example:

func TestMain(m *testing.M) {
  os.Exit(bazel_testing.TestMain(m, bazel_testing.Args{...}))
}

TestMain constructs a set of workspaces and changes the working directory to the main workspace.

Types

type Args

type Args struct {
	// Main is a text archive containing files in the main workspace.
	// The text archive format is parsed by
	// //go/tools/internal/txtar:go_default_library, which is copied from
	// cmd/go/internal/txtar. If this archive does not contain a WORKSPACE file,
	// a default file will be synthesized.
	Main string

	// WorkspaceSuffix is a string that should be appended to the end
	// of the default generated WORKSPACE file.
	WorkspaceSuffix string
}

Args is a list of arguments to TestMain. It's defined as a struct so that new optional arguments may be added without breaking compatibility.

type StderrExitError

type StderrExitError struct {
	Err *exec.ExitError
}

StderrExitError wraps *exec.ExitError and prints the complete stderr output from a command.

func (*StderrExitError) Error

func (e *StderrExitError) Error() string

Jump to

Keyboard shortcuts

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