fakeloader

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Overview

Package fakeloader contains a hermetic loader implementation that does not depend on any other systems and can be used in tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFakeLoader

func NewFakeLoader(pkgs map[string][]string, files, generated map[string]string, exportFor ExportForFunc) loader.Loader

NewFakeLoader returns a Loader that can be used in tests. It works in the same way as loader returned from NewLoader, except it fakes expensive/flaky dependencies (e.g. executing commands).

pkgs maps target rule names (e.g. "//base/go:flag") to list of files in that package (e.g. "net/proto2/go/open2opaque/testdata/dummycmd.go"). File paths should be in the form expected by blaze, e.g. "//net/proto2/go/open2opaque/testdata:dummy.go". Names of test packages should have "_test" suffix.

files maps all files (e.g. "//test/pkg:updated.go"), referenced by the pkgs map, to their content. generated maps generated files (e.g. "//test/pkg:generated.go"), referenced by the pkgs map, to ther content.

Unlike the loader returned by NewLoader, the fake loader is inexpensive. It's intended that multiple fake loaders are created (perhaps one per test).

Types

type ExportForFunc

type ExportForFunc func(importPath string) []byte

ExportForFunc is a caller-supplied function that returns the export data (.x file) for the package with the specified import path.

Jump to

Keyboard shortcuts

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