Documentation
¶
Overview ¶
Package parser contains methods to parse and restructure log output from go testing and terratest.
Index ¶
- Variables
- func EnsureDirectoryExists(logger *logrus.Logger, dirName string) error
- func GetIndent(data string) string
- func GetTestNameFromResultLine(text string) string
- func GetTestNameFromStatusLine(text string) string
- func IsPanicLine(text string) bool
- func IsResultLine(text string) bool
- func IsStatusLine(text string) bool
- func IsSummaryLine(text string) bool
- func SpawnParsers(logger *logrus.Logger, reader io.Reader, outputDir string)
- type LogWriter
- type TestResultMarker
- type TestResultMarkerStack
- func (s TestResultMarkerStack) IsEmpty() bool
- func (s TestResultMarkerStack) Peek() TestResultMarker
- func (s TestResultMarkerStack) Pop() (TestResultMarkerStack, TestResultMarker)
- func (s TestResultMarkerStack) Push(v TestResultMarker) TestResultMarkerStack
- func (s TestResultMarkerStack) RemoveDedentedTestResultMarkers(currentIndentLevel int) TestResultMarkerStack
Constants ¶
This section is empty.
Variables ¶
var NULL_TEST_RESULT_MARKER = NullTestResultMarker //nolint:revive
NULL_TEST_RESULT_MARKER is deprecated: Use NullTestResultMarker instead.
var NullTestResultMarker = TestResultMarker{}
NullTestResultMarker is a blank TestResultMarker considered null. Used when peeking or popping an empty stack.
Functions ¶
func EnsureDirectoryExists ¶ added in v1.0.0
EnsureDirectoryExists will only attempt to create the directory if it does not exist.
func GetIndent ¶ added in v1.0.0
GetIndent takes a line and returns the indent string Example:
in: " --- FAIL: TestSnafu" out: " "
func GetTestNameFromResultLine ¶ added in v1.0.0
GetTestNameFromResultLine takes a go testing result line and extracts out the test name Example:
in: --- FAIL: TestSnafu out: TestSnafu
func GetTestNameFromStatusLine ¶ added in v1.0.0
GetTestNameFromStatusLine takes a go testing status line and extracts out the test name Example:
in: === RUN TestSnafu out: TestSnafu
func IsPanicLine ¶ added in v1.0.0
IsPanicLine checks if a line of text matches a panic
func IsResultLine ¶ added in v1.0.0
IsResultLine checks if a line of text matches a test result (begins with "--- FAIL" or "--- PASS")
func IsStatusLine ¶ added in v1.0.0
IsStatusLine checks if a line of text matches a test status
func IsSummaryLine ¶ added in v1.0.0
IsSummaryLine checks if a line of text matches the test summary
Types ¶
type LogWriter ¶
type LogWriter struct {
// Lookup represents an open file to a log corresponding to a test (key = test name).
Lookup map[string]*os.File
// OutputDir is the directory where log files are written.
OutputDir string
}
LogWriter manages file handles for writing test log output, keyed by test name.
func (LogWriter) CloseFiles ¶ added in v1.0.0
CloseFiles closes all the file handles in the Lookup dictionary.
type TestResultMarker ¶
TestResultMarker tracks the indentation level of a test result line in go test output. Example: --- FAIL: TestSnafu
--- PASS: TestSnafu/Situation --- FAIL: TestSnafu/Normal
The three markers for the above in order are: TestResultMarker{TestName: "TestSnafu", IndentLevel: 0} TestResultMarker{TestName: "TestSnafu/Situation", IndentLevel: 4} TestResultMarker{TestName: "TestSnafu/Normal", IndentLevel: 4}
type TestResultMarkerStack ¶
type TestResultMarkerStack []TestResultMarker
TestResultMarkerStack is a stack data structure to store TestResultMarkers.
func (TestResultMarkerStack) IsEmpty ¶ added in v1.0.0
func (s TestResultMarkerStack) IsEmpty() bool
IsEmpty will return whether or not the stack is empty.
func (TestResultMarkerStack) Peek ¶ added in v1.0.0
func (s TestResultMarkerStack) Peek() TestResultMarker
Peek will return the top TestResultMarker from the stack, but will not remove it.
func (TestResultMarkerStack) Pop ¶ added in v1.0.0
func (s TestResultMarkerStack) Pop() (TestResultMarkerStack, TestResultMarker)
Pop will pop a TestResultMarker object off of the stack, returning the new one with the popped marker. When stack is empty, will return an empty object.
func (TestResultMarkerStack) Push ¶ added in v1.0.0
func (s TestResultMarkerStack) Push(v TestResultMarker) TestResultMarkerStack
Push will push a TestResultMarker object onto the stack, returning the new one.
func (TestResultMarkerStack) RemoveDedentedTestResultMarkers ¶ added in v1.0.0
func (s TestResultMarkerStack) RemoveDedentedTestResultMarkers(currentIndentLevel int) TestResultMarkerStack
RemoveDedentedTestResultMarkers will pop items off of the stack of TestResultMarker objects until the top most item has an indent level less than the current indent level. Assumes that the stack is ordered, in that recently pushed items in the stack have higher indent levels.