Documentation
¶
Overview ¶
Parses and interprets the CodeQL betterjson test output format.
Index ¶
- func LogResults(results []TestResult) (passed, failed int)
- func RunUnitTests(base, lang, codeqlArgs string, reportOutput *string, numThreads int) error
- func WriteReport(path string, r *TestReport) error
- type Event
- type Message
- type ReportMetadata
- type ReportSummary
- type Summary
- type TestMessage
- type TestReport
- type TestResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LogResults ¶
func LogResults(results []TestResult) (passed, failed int)
LogResults emits one PASS/FAIL slog line per result and returns the counts.
func RunUnitTests ¶
RunUnitTests resolves and runs all CodeQL unit tests for the given language under base, reporting a summary via slog. A TestReport is written to disk only when reportOutput is non-nil:
- reportOutput == nil → no report written
- *reportOutput == "" → <base>/target/test/test-report-<timestamp>.json
- *reportOutput != "" → the caller-supplied path
func WriteReport ¶
func WriteReport(path string, r *TestReport) error
WriteReport writes r to path as indented JSON, creating parent directories as needed.
Types ¶
type Event ¶
type Event struct {
Type string `json:"type"`
Test string `json:"test,omitempty"`
TestDirectory string `json:"testDirectory,omitempty"`
DatasetDirectory string `json:"datasetDirectory,omitempty"`
Pass bool `json:"pass,omitempty"`
Messages []Message `json:"messages,omitempty"`
CompilationMs int `json:"compilationMs,omitempty"`
EvaluationMs int `json:"evaluationMs,omitempty"`
Expected string `json:"expected,omitempty"`
FailureMessage string `json:"failureMessage,omitempty"`
}
Event represents a single event from the CodeQL betterjson output format.
type Message ¶
type Message struct {
Message string `json:"message,omitempty"`
Severity string `json:"severity,omitempty"`
}
Message is an inline diagnostic message attached to a testCompleted event.
type ReportMetadata ¶
type ReportSummary ¶
type TestMessage ¶
type TestReport ¶
type TestReport struct {
Metadata ReportMetadata `json:"metadata"`
Summary ReportSummary `json:"summary"`
Results []TestResult `json:"results"`
}
TestReport is the qlt-owned artifact produced by RunUnitTests. It is stable within qlt and decoupled from codeql's CLI output format.
type TestResult ¶
type TestResult struct {
Name string `json:"name"`
Path string `json:"path"`
Pass bool `json:"pass"`
CompilationMs int `json:"compilationMs"`
EvaluationMs int `json:"evaluationMs"`
Expected string `json:"expected,omitempty"`
Messages []TestMessage `json:"messages,omitempty"`
}
func ParseResults ¶
func ParseResults(data []byte) ([]TestResult, error)
ParseResults decodes codeql's --format=json output into qlt TestResult values.