smoke

package
v0.0.30 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2019 License: Apache-2.0, NCSA Imports: 9 Imported by: 0

Documentation

Overview

Package smoke is a basic harness for testing the validity of config.ExtractRepo output.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EmptyIndexer

func EmptyIndexer(ctx context.Context, inputDir, outputDir string) error

EmptyIndexer does nothing - it is a placeholder.

func GitFetch

func GitFetch(ctx context.Context, repo, outputPath string) error

GitFetch fetches repos using git commandline.

Types

type Fetcher

type Fetcher func(ctx context.Context, repo, outputPath string) error

Fetcher is fetches a given repo and writes it to an output directory.

type Harness

type Harness struct {
	Fetcher    Fetcher          // defaults to GitFetch
	Extractor  config.Extractor // defaults to config.ExtractRepo
	Indexer    Indexer          // defaults to EmptyIndexer
	ConfigPath string           // defaults to ""
}

A Harness contains all the settings necessary to test a repository. All fields are optional and use defaults as specified. Note that a default ConfigPath tries to use per-repository configuration files.

func (Harness) TestRepo

func (h Harness) TestRepo(ctx context.Context, repo string) (Result, error)

TestRepo compares the result of extraction and optional indexing with expected output from a given repo.

type Indexer

type Indexer func(ctx context.Context, inputDir, outputDir string) error

Indexer takes .kindex files in a given inputDir, indexes them, and deposits in outputDir.

TODO(danielmoy): kzip? This is generally a thing that needs supporting in smoke.go and related files now that I think about it.

type Result

type Result struct {
	// Whether the repo was successfully downloaded, extracted, or indexed.
	Downloaded, Extracted, Indexed bool
	// The number of downloaded and extracted files, and the number of
	// indexed symbols.
	DownloadCount, ExtractCount, IndexCount int
	// The percentage of files in the repo that are covered by extraction.
	// Should be in range [0.0, 1.0]
	FileCoverage float64
}

Result is a simple container for the results of a single repo test. It may contain useful information about whether or not the repo was accessible, extracted at all, or the extent to which we got good file coverage from the extraction.

TODO(danielmoy): consider better metrics here. For example consider having the smoke test harness try to run a kythe indexer in addition to an extraction and see how much symbol coverage we have. This might be out of scope for a simple smoke test harness though.

type Tester

type Tester func(ctx context.Context, repo string) (Result, error)

Tester checks the validity of config.ExtractRepo.

It does this in a generic way by simply trying to determine expected output automatically. The current implementation is to simply check the fraction of files covered by extractor output.

Also optionally supports indexing the extractors output.

Jump to

Keyboard shortcuts

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