output

package
v0.2.0-alpha Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package output holds various output options

Package output provides formatters for Reglet execution results.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JSONFormatter

type JSONFormatter struct {
	// contains filtered or unexported fields
}

JSONFormatter formats execution results as JSON.

func NewJSONFormatter

func NewJSONFormatter(w io.Writer, indent bool) *JSONFormatter

NewJSONFormatter creates a new JSON formatter. If indent is true, the output will be pretty-printed with indentation.

func (*JSONFormatter) Format

func (f *JSONFormatter) Format(result *execution.ExecutionResult) error

Format writes the execution result as JSON.

type JUnitError

type JUnitError struct {
	Message string `xml:"message,attr"`
	Content string `xml:",chardata"`
}

JUnitError represents a test case that encountered an error.

type JUnitFailure

type JUnitFailure struct {
	Message string `xml:"message,attr"`
	Content string `xml:",chardata"`
}

JUnitFailure represents a failed test case.

type JUnitFormatter

type JUnitFormatter struct {
	// contains filtered or unexported fields
}

JUnitFormatter formats execution results as JUnit XML.

func NewJUnitFormatter

func NewJUnitFormatter(w io.Writer) *JUnitFormatter

NewJUnitFormatter creates a new JUnit formatter.

func (*JUnitFormatter) Format

func (f *JUnitFormatter) Format(result *execution.ExecutionResult) error

Format writes the execution result as JUnit XML.

type JUnitSkipped

type JUnitSkipped struct {
	Message string `xml:"message,attr,omitempty"`
}

JUnitSkipped represents a skipped test case.

type JUnitTestCase

type JUnitTestCase struct {
	XMLName   xml.Name      `xml:"testcase"`
	Name      string        `xml:"name,attr"`
	ClassName string        `xml:"classname,attr"`
	Time      float64       `xml:"time,attr"`
	Failure   *JUnitFailure `xml:"failure,omitempty"`
	Error     *JUnitError   `xml:"error,omitempty"`
	Skipped   *JUnitSkipped `xml:"skipped,omitempty"`
}

JUnitTestCase represents a single test case in JUnit XML.

type JUnitTestSuite

type JUnitTestSuite struct {
	XMLName   xml.Name        `xml:"testsuite"`
	Name      string          `xml:"name,attr"`
	Tests     int             `xml:"tests,attr"`
	Failures  int             `xml:"failures,attr"`
	Errors    int             `xml:"errors,attr"`
	Skipped   int             `xml:"skipped,attr"`
	Time      float64         `xml:"time,attr"`
	TestCases []JUnitTestCase `xml:"testcase"`
}

JUnitTestSuite represents a single test suite in JUnit XML.

type JUnitTestSuites

type JUnitTestSuites struct {
	XMLName    xml.Name         `xml:"testsuites"`
	Name       string           `xml:"name,attr"`
	Tests      int              `xml:"tests,attr"`
	Failures   int              `xml:"failures,attr"`
	Errors     int              `xml:"errors,attr"`
	Time       float64          `xml:"time,attr"`
	TestSuites []JUnitTestSuite `xml:"testsuite"`
}

JUnitTestSuites JUnit XML structures

type SARIFFormatter

type SARIFFormatter struct {
	// contains filtered or unexported fields
}

SARIFFormatter formats execution results as SARIF 2.1.0 JSON. It maps Reglet controls to SARIF rules and observations to results with locations.

Usage:

formatter := output.NewSARIFFormatter(os.Stdout, "profile.yaml")
if err := formatter.Format(result); err != nil {
    log.Fatal(err)
}

func NewSARIFFormatter

func NewSARIFFormatter(writer io.Writer, profilePath string) *SARIFFormatter

NewSARIFFormatter creates a new SARIF formatter. profilePath is used to resolve relative paths for file locations.

func (*SARIFFormatter) Format

func (f *SARIFFormatter) Format(result *execution.ExecutionResult) error

Format writes the execution result as SARIF 2.1.0 JSON. Returns error if SARIF creation or marshaling fails.

type TableFormatter

type TableFormatter struct {
	EnableColor bool
	// contains filtered or unexported fields
}

TableFormatter formats execution results as a human-readable table.

func NewTableFormatter

func NewTableFormatter(w io.Writer) *TableFormatter

NewTableFormatter creates a new table formatter.

func (*TableFormatter) Format

func (f *TableFormatter) Format(result *execution.ExecutionResult) error

Format writes the execution result as a table.

type YAMLFormatter

type YAMLFormatter struct {
	// contains filtered or unexported fields
}

YAMLFormatter formats execution results as YAML.

func NewYAMLFormatter

func NewYAMLFormatter(w io.Writer) *YAMLFormatter

NewYAMLFormatter creates a new YAML formatter.

func (*YAMLFormatter) Format

func (f *YAMLFormatter) Format(result *execution.ExecutionResult) error

Format writes the execution result as YAML.

Jump to

Keyboard shortcuts

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