Skip to content

feat: add timestamp field for test suite #51

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions ingest.go
Original file line number Diff line number Diff line change
@@ -30,6 +30,12 @@ func ingestSuite(root xmlNode) Suite {
Package: root.Attr("package"),
Properties: root.Attrs,
}
if root.Attr("timestamp") != "" {
const layout = "2006-01-02T15:04:05"
if timestamp, err := time.Parse(layout, root.Attr("timestamp")); err == nil {
suite.Timestamp = timestamp
}
}

for _, node := range root.Nodes {
switch node.XMLName.Local {
6 changes: 6 additions & 0 deletions ingest_test.go
Original file line number Diff line number Diff line change
@@ -27,6 +27,9 @@ func TestExamplesInTheWild(t *testing.T) {
assertLen(t, suites[0].Tests, 0)
assertLen(t, suites[1].Tests, 3)
assertError(t, suites[1].Tests[0].Error, "Assertion failed")

suite := suites[1]
assertEqual(t, false, suite.Timestamp.IsZero())
},
},
{
@@ -40,6 +43,9 @@ func TestExamplesInTheWild(t *testing.T) {
assertEqual(t, "STDERR text", suites[0].SystemErr)
assertEqual(t, "STDOUT text", suites[0].Tests[0].SystemOut)
assertEqual(t, "STDERR text", suites[0].Tests[0].SystemErr)

suite := suites[0]
assertEqual(t, true, suite.Timestamp.IsZero())
},
},
{
3 changes: 3 additions & 0 deletions types.go
Original file line number Diff line number Diff line change
@@ -79,6 +79,9 @@ type Suite struct {
// Suites is an ordered collection of suites with associated tests.
Suites []Suite `json:"suites,omitempty" yaml:"suites,omitempty"`

// Timestamp is the time at which the suite was run, date and time in ISO8601.
Timestamp time.Time `json:"timestamp,omitempty" yaml:"timestamp,omitempty"`

// SystemOut is textual test output for the suite. Usually output that is
// written to stdout.
SystemOut string `json:"stdout,omitempty" yaml:"stdout,omitempty"`