Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
6da0d384
Commit
6da0d384
authored
May 16, 2017
by
Kris
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add JUnit structs for encoding JUnit XML
parent
2ab03207
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
135 additions
and
1 deletion
+135
-1
BUILD
test/utils/BUILD
+4
-1
BUILD
test/utils/junit/BUILD
+27
-0
junit.go
test/utils/junit/junit.go
+104
-0
No files found.
test/utils/BUILD
View file @
6da0d384
...
...
@@ -59,6 +59,9 @@ filegroup(
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
srcs = [
":package-srcs",
"//test/utils/junit:all-srcs",
],
tags = ["automanaged"],
)
test/utils/junit/BUILD
0 → 100644
View file @
6da0d384
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = ["junit.go"],
tags = ["automanaged"],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
)
test/utils/junit/junit.go
0 → 100644
View file @
6da0d384
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Package junit provides data structures to allow easy XML encoding
// and decoding of JUnit test results.
package
junit
import
(
"encoding/xml"
"time"
)
// TestSuite is a top-level test suite containing test cases.
type
TestSuite
struct
{
XMLName
xml
.
Name
`xml:"testsuite"`
Name
string
`xml:"name,attr"`
Tests
int
`xml:"tests,attr"`
Disabled
int
`xml:"disabled,attr,omitempty"`
Errors
int
`xml:"errors,attr"`
Failures
int
`xml:"failures,attr"`
Skipped
int
`xml:"skipped,attr,omitempty"`
Time
float64
`xml:"time,attr"`
Timestamp
time
.
Time
`xml:"timestamp,attr"`
ID
int
`xml:"id,attr,omitempty"`
Package
string
`xml:"package,attr,omitempty"`
Hostname
string
`xml:"hostname,attr"`
Properties
[]
*
Property
`xml:"properties,omitempty"`
TestCases
[]
*
TestCase
`xml:"testcase"`
SystemOut
string
`xml:"system-out,omitempty"`
SystemErr
string
`xml:"system-err,omitempty"`
}
// Update iterates through the TestCases and updates Tests, Errors,
// Failures, and Skipped top level attributes.
func
(
t
*
TestSuite
)
Update
()
{
t
.
Tests
=
len
(
t
.
TestCases
)
for
_
,
tc
:=
range
t
.
TestCases
{
t
.
Errors
+=
len
(
tc
.
Errors
)
t
.
Failures
+=
len
(
tc
.
Failures
)
if
len
(
tc
.
Skipped
)
>
0
{
t
.
Skipped
++
}
}
}
// Property is a simple key-value property that can be attached to a TestSuite.
type
Property
struct
{
XMLName
xml
.
Name
`xml:"property"`
Name
string
`xml:"name,attr"`
Value
string
`xml:"value,attr"`
}
// Error represents the errors in a test case.
type
Error
struct
{
XMLName
xml
.
Name
`xml:"error"`
Message
string
`xml:"message,attr,omitempty"`
Type
string
`xml:"type,attr"`
Value
string
`xml:",cdata"`
}
// Failure represents the failures in a test case.
type
Failure
struct
{
XMLName
xml
.
Name
`xml:"failure"`
Message
string
`xml:"message,attr,omitempty"`
Type
string
`xml:"type,attr"`
Value
string
`xml:",cdata"`
}
// TestCase represents a single test case within a suite.
type
TestCase
struct
{
XMLName
xml
.
Name
`xml:"testcase"`
Name
string
`xml:"name,attr"`
Classname
string
`xml:"classname,attr"`
Status
string
`xml:"status,attr,omitempty"`
Assertions
int
`xml:"assertions,attr,omitempty"`
Time
float64
`xml:"time,attr"`
Skipped
string
`xml:"skipped,omitempty"`
Errors
[]
*
Error
`xml:"error,omitempty"`
Failures
[]
*
Failure
`xml:"failure,omitempty"`
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment