aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/t-yuki
diff options
context:
space:
mode:
authorTaras Madan <tarasmadan@google.com>2024-09-10 12:16:33 +0200
committerTaras Madan <tarasmadan@google.com>2024-09-10 14:05:26 +0000
commitc97c816133b42257d0bcf1ee4bd178bb2a7a2b9e (patch)
tree0bcbc2e540bbf8f62f6c17887cdd53b8c2cee637 /vendor/github.com/t-yuki
parent54e657429ab892ad06c90cd7c1a4eb33ba93a3dc (diff)
vendor: update
Diffstat (limited to 'vendor/github.com/t-yuki')
-rw-r--r--vendor/github.com/t-yuki/gocover-cobertura/.travis.yml12
-rw-r--r--vendor/github.com/t-yuki/gocover-cobertura/LICENSE19
-rw-r--r--vendor/github.com/t-yuki/gocover-cobertura/README.md35
-rw-r--r--vendor/github.com/t-yuki/gocover-cobertura/cobertura.go178
-rw-r--r--vendor/github.com/t-yuki/gocover-cobertura/gocover-cobertura.go176
-rw-r--r--vendor/github.com/t-yuki/gocover-cobertura/profile.go202
6 files changed, 0 insertions, 622 deletions
diff --git a/vendor/github.com/t-yuki/gocover-cobertura/.travis.yml b/vendor/github.com/t-yuki/gocover-cobertura/.travis.yml
deleted file mode 100644
index f17bb6169..000000000
--- a/vendor/github.com/t-yuki/gocover-cobertura/.travis.yml
+++ /dev/null
@@ -1,12 +0,0 @@
-language: go
-go:
- - 1.6
- - 1.7
- - 1.8
- - tip
-
-sudo: false
-before_install:
- - go get github.com/mattn/goveralls
-script:
- - $GOPATH/bin/goveralls -service=travis-ci
diff --git a/vendor/github.com/t-yuki/gocover-cobertura/LICENSE b/vendor/github.com/t-yuki/gocover-cobertura/LICENSE
deleted file mode 100644
index 7ec1b3d85..000000000
--- a/vendor/github.com/t-yuki/gocover-cobertura/LICENSE
+++ /dev/null
@@ -1,19 +0,0 @@
-Copyright (c) 2013 Yukinari Toyota
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of
-this software and associated documentation files (the "Software"), to deal in
-the Software without restriction, including without limitation the rights to
-use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-of the Software, and to permit persons to whom the Software is furnished to do
-so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
diff --git a/vendor/github.com/t-yuki/gocover-cobertura/README.md b/vendor/github.com/t-yuki/gocover-cobertura/README.md
deleted file mode 100644
index 60ab1dbe7..000000000
--- a/vendor/github.com/t-yuki/gocover-cobertura/README.md
+++ /dev/null
@@ -1,35 +0,0 @@
-[![Build Status](https://travis-ci.org/t-yuki/gocover-cobertura.svg?branch=master)](https://travis-ci.org/t-yuki/gocover-cobertura)
-[![Coverage Status](https://coveralls.io/repos/github/t-yuki/gocover-cobertura/badge.svg?branch=master)](https://coveralls.io/github/t-yuki/gocover-cobertura?branch=master)
-
-go tool cover XML (Cobertura) export
-====================================
-
-This is a simple helper tool for generating XML output in [Cobertura](http://cobertura.sourceforge.net/) format
-for CIs like [Jenkins](https://wiki.jenkins-ci.org/display/JENKINS/Cobertura+Plugin) and others
-from [go tool cover](https://code.google.com/p/go.tools/) output.
-
-Installation
-------------
-
-Just type the following to install the program and its dependencies:
-
- $ go get code.google.com/p/go.tools/cmd/cover
- $ go get github.com/t-yuki/gocover-cobertura
-
-Usage
------
-
-`gocover-cobertura` reads from the standard input:
-
- $ go test -coverprofile=coverage.txt -covermode count github.com/gorilla/mux
- $ gocover-cobertura < coverage.txt > coverage.xml
-
-Authors
--------
-
-* [Yukinari Toyota (t-yuki)](https://github.com/t-yuki)
-
-Thanks
-------
-
-This tool is originated from [gocov-xml](https://github.com/AlekSi/gocov-xml) by [Alexey Palazhchenko (AlekSi)](https://github.com/AlekSi)
diff --git a/vendor/github.com/t-yuki/gocover-cobertura/cobertura.go b/vendor/github.com/t-yuki/gocover-cobertura/cobertura.go
deleted file mode 100644
index 8556dc563..000000000
--- a/vendor/github.com/t-yuki/gocover-cobertura/cobertura.go
+++ /dev/null
@@ -1,178 +0,0 @@
-package main
-
-import (
- "encoding/xml"
-)
-
-type Coverage struct {
- XMLName xml.Name `xml:"coverage"`
- LineRate float32 `xml:"line-rate,attr"`
- BranchRate float32 `xml:"branch-rate,attr"`
- Version string `xml:"version,attr"`
- Timestamp int64 `xml:"timestamp,attr"`
- LinesCovered int64 `xml:"lines-covered,attr"`
- LinesValid int64 `xml:"lines-valid,attr"`
- BranchesCovered int64 `xml:"branches-covered,attr"`
- BranchesValid int64 `xml:"branches-valid,attr"`
- Complexity float32 `xml:"complexity,attr"`
- Sources []*Source `xml:"sources>source"`
- Packages []*Package `xml:"packages>package"`
-}
-
-type Source struct {
- Path string `xml:",chardata"`
-}
-
-type Package struct {
- Name string `xml:"name,attr"`
- LineRate float32 `xml:"line-rate,attr"`
- BranchRate float32 `xml:"branch-rate,attr"`
- Complexity float32 `xml:"complexity,attr"`
- Classes []*Class `xml:"classes>class"`
-}
-
-type Class struct {
- Name string `xml:"name,attr"`
- Filename string `xml:"filename,attr"`
- LineRate float32 `xml:"line-rate,attr"`
- BranchRate float32 `xml:"branch-rate,attr"`
- Complexity float32 `xml:"complexity,attr"`
- Methods []*Method `xml:"methods>method"`
- Lines Lines `xml:"lines>line"`
-}
-
-type Method struct {
- Name string `xml:"name,attr"`
- Signature string `xml:"signature,attr"`
- LineRate float32 `xml:"line-rate,attr"`
- BranchRate float32 `xml:"branch-rate,attr"`
- Complexity float32 `xml:"complexity,attr"`
- Lines Lines `xml:"lines>line"`
-}
-
-type Line struct {
- Number int `xml:"number,attr"`
- Hits int64 `xml:"hits,attr"`
-}
-
-// Lines is a slice of Line pointers, with some convenience methods
-type Lines []*Line
-
-// HitRate returns a float32 from 0.0 to 1.0 representing what fraction of lines
-// have hits
-func (lines Lines) HitRate() (hitRate float32) {
- return float32(lines.NumLinesWithHits()) / float32(len(lines))
-}
-
-// NumLines returns the number of lines
-func (lines Lines) NumLines() int64 {
- return int64(len(lines))
-}
-
-// NumLinesWithHits returns the number of lines with a hit count > 0
-func (lines Lines) NumLinesWithHits() (numLinesWithHits int64) {
- for _, line := range lines {
- if line.Hits > 0 {
- numLinesWithHits++
- }
- }
- return numLinesWithHits
-}
-
-// AddOrUpdateLine adds a line if it is a different line than the last line recorded.
-// If it's the same line as the last line recorded then we update the hits down
-// if the new hits is less; otherwise just leave it as-is
-func (lines *Lines) AddOrUpdateLine(lineNumber int, hits int64) {
- if len(*lines) > 0 {
- lastLine := (*lines)[len(*lines)-1]
- if lineNumber == lastLine.Number {
- if hits < lastLine.Hits {
- lastLine.Hits = hits
- }
- return
- }
- }
- *lines = append(*lines, &Line{Number: lineNumber, Hits: hits})
-}
-
-// HitRate returns a float32 from 0.0 to 1.0 representing what fraction of lines
-// have hits
-func (method Method) HitRate() float32 {
- return method.Lines.HitRate()
-}
-
-// NumLines returns the number of lines
-func (method Method) NumLines() int64 {
- return method.Lines.NumLines()
-}
-
-// NumLinesWithHits returns the number of lines with a hit count > 0
-func (method Method) NumLinesWithHits() int64 {
- return method.Lines.NumLinesWithHits()
-}
-
-// HitRate returns a float32 from 0.0 to 1.0 representing what fraction of lines
-// have hits
-func (class Class) HitRate() float32 {
- return float32(class.NumLinesWithHits()) / float32(class.NumLines())
-}
-
-// NumLines returns the number of lines
-func (class Class) NumLines() (numLines int64) {
- for _, method := range class.Methods {
- numLines += method.NumLines()
- }
- return numLines
-}
-
-// NumLinesWithHits returns the number of lines with a hit count > 0
-func (class Class) NumLinesWithHits() (numLinesWithHits int64) {
- for _, method := range class.Methods {
- numLinesWithHits += method.NumLinesWithHits()
- }
- return numLinesWithHits
-}
-
-// HitRate returns a float32 from 0.0 to 1.0 representing what fraction of lines
-// have hits
-func (pkg Package) HitRate() float32 {
- return float32(pkg.NumLinesWithHits()) / float32(pkg.NumLines())
-}
-
-// NumLines returns the number of lines
-func (pkg Package) NumLines() (numLines int64) {
- for _, class := range pkg.Classes {
- numLines += class.NumLines()
- }
- return numLines
-}
-
-// NumLinesWithHits returns the number of lines with a hit count > 0
-func (pkg Package) NumLinesWithHits() (numLinesWithHits int64) {
- for _, class := range pkg.Classes {
- numLinesWithHits += class.NumLinesWithHits()
- }
- return numLinesWithHits
-}
-
-// HitRate returns a float32 from 0.0 to 1.0 representing what fraction of lines
-// have hits
-func (cov Coverage) HitRate() float32 {
- return float32(cov.NumLinesWithHits()) / float32(cov.NumLines())
-}
-
-// NumLines returns the number of lines
-func (cov Coverage) NumLines() (numLines int64) {
- for _, pkg := range cov.Packages {
- numLines += pkg.NumLines()
- }
- return numLines
-}
-
-// NumLinesWithHits returns the number of lines with a hit count > 0
-func (cov Coverage) NumLinesWithHits() (numLinesWithHits int64) {
- for _, pkg := range cov.Packages {
- numLinesWithHits += pkg.NumLinesWithHits()
- }
- return numLinesWithHits
-}
diff --git a/vendor/github.com/t-yuki/gocover-cobertura/gocover-cobertura.go b/vendor/github.com/t-yuki/gocover-cobertura/gocover-cobertura.go
deleted file mode 100644
index e64b5de02..000000000
--- a/vendor/github.com/t-yuki/gocover-cobertura/gocover-cobertura.go
+++ /dev/null
@@ -1,176 +0,0 @@
-package main
-
-import (
- "encoding/xml"
- "fmt"
- "go/ast"
- "go/build"
- "go/parser"
- "go/token"
- "io"
- "io/ioutil"
- "os"
- "path/filepath"
- "strings"
- "time"
-)
-
-const coberturaDTDDecl = "<!DOCTYPE coverage SYSTEM \"http://cobertura.sourceforge.net/xml/coverage-04.dtd\">\n"
-
-func main() {
- convert(os.Stdin, os.Stdout)
-}
-
-func convert(in io.Reader, out io.Writer) {
- profiles, err := ParseProfiles(in)
- if err != nil {
- panic("Can't parse profiles")
- }
-
- srcDirs := build.Default.SrcDirs()
- sources := make([]*Source, len(srcDirs))
- for i, dir := range srcDirs {
- sources[i] = &Source{dir}
- }
-
- coverage := Coverage{Sources: sources, Packages: nil, Timestamp: time.Now().UnixNano() / int64(time.Millisecond)}
- coverage.parseProfiles(profiles)
-
- fmt.Fprintf(out, xml.Header)
- fmt.Fprintf(out, coberturaDTDDecl)
-
- encoder := xml.NewEncoder(out)
- encoder.Indent("", "\t")
- err = encoder.Encode(coverage)
- if err != nil {
- panic(err)
- }
-
- fmt.Fprintln(out)
-}
-
-func (cov *Coverage) parseProfiles(profiles []*Profile) error {
- cov.Packages = []*Package{}
- for _, profile := range profiles {
- cov.parseProfile(profile)
- }
- cov.LinesValid = cov.NumLines()
- cov.LinesCovered = cov.NumLinesWithHits()
- cov.LineRate = cov.HitRate()
- return nil
-}
-
-func (cov *Coverage) parseProfile(profile *Profile) error {
- fileName := profile.FileName
- absFilePath, err := findFile(fileName)
- if err != nil {
- return err
- }
- fset := token.NewFileSet()
- parsed, err := parser.ParseFile(fset, absFilePath, nil, 0)
- if err != nil {
- return err
- }
- data, err := ioutil.ReadFile(absFilePath)
- if err != nil {
- return err
- }
-
- pkgPath, _ := filepath.Split(fileName)
- pkgPath = strings.TrimRight(pkgPath, string(os.PathSeparator))
-
- var pkg *Package
- for _, p := range cov.Packages {
- if p.Name == pkgPath {
- pkg = p
- }
- }
- if pkg == nil {
- pkg = &Package{Name: pkgPath, Classes: []*Class{}}
- cov.Packages = append(cov.Packages, pkg)
- }
- visitor := &fileVisitor{
- fset: fset,
- fileName: fileName,
- fileData: data,
- classes: make(map[string]*Class),
- pkg: pkg,
- profile: profile,
- }
- ast.Walk(visitor, parsed)
- pkg.LineRate = pkg.HitRate()
- return nil
-}
-
-type fileVisitor struct {
- fset *token.FileSet
- fileName string
- fileData []byte
- pkg *Package
- classes map[string]*Class
- profile *Profile
-}
-
-func (v *fileVisitor) Visit(node ast.Node) ast.Visitor {
- switch n := node.(type) {
- case *ast.FuncDecl:
- class := v.class(n)
- method := v.method(n)
- method.LineRate = method.Lines.HitRate()
- class.Methods = append(class.Methods, method)
- for _, line := range method.Lines {
- class.Lines = append(class.Lines, line)
- }
- class.LineRate = class.Lines.HitRate()
- }
- return v
-}
-
-func (v *fileVisitor) method(n *ast.FuncDecl) *Method {
- method := &Method{Name: n.Name.Name}
- method.Lines = []*Line{}
-
- start := v.fset.Position(n.Pos())
- end := v.fset.Position(n.End())
- startLine := start.Line
- startCol := start.Column
- endLine := end.Line
- endCol := end.Column
- // The blocks are sorted, so we can stop counting as soon as we reach the end of the relevant block.
- for _, b := range v.profile.Blocks {
- if b.StartLine > endLine || (b.StartLine == endLine && b.StartCol >= endCol) {
- // Past the end of the function.
- break
- }
- if b.EndLine < startLine || (b.EndLine == startLine && b.EndCol <= startCol) {
- // Before the beginning of the function
- continue
- }
- for i := b.StartLine; i <= b.EndLine; i++ {
- method.Lines.AddOrUpdateLine(i, int64(b.Count))
- }
- }
- return method
-}
-
-func (v *fileVisitor) class(n *ast.FuncDecl) *Class {
- className := v.recvName(n)
- var class *Class = v.classes[className]
- if class == nil {
- class = &Class{Name: className, Filename: v.fileName, Methods: []*Method{}, Lines: []*Line{}}
- v.classes[className] = class
- v.pkg.Classes = append(v.pkg.Classes, class)
- }
- return class
-}
-
-func (v *fileVisitor) recvName(n *ast.FuncDecl) string {
- if n.Recv == nil {
- return "-"
- }
- recv := n.Recv.List[0].Type
- start := v.fset.Position(recv.Pos())
- end := v.fset.Position(recv.End())
- name := string(v.fileData[start.Offset:end.Offset])
- return strings.TrimSpace(strings.TrimLeft(name, "*"))
-}
diff --git a/vendor/github.com/t-yuki/gocover-cobertura/profile.go b/vendor/github.com/t-yuki/gocover-cobertura/profile.go
deleted file mode 100644
index 99cbac234..000000000
--- a/vendor/github.com/t-yuki/gocover-cobertura/profile.go
+++ /dev/null
@@ -1,202 +0,0 @@
-// Imported from https://code.google.com/p/go/source/browse/cmd/cover/profile.go?repo=tools&r=c10a9dd5e0b0a859a8385b6f004584cb083a3934
-
-// Copyright 2013 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package main
-
-import (
- "bufio"
- "fmt"
- "go/build"
- "io"
- "math"
- "os"
- "path/filepath"
- "regexp"
- "sort"
- "strconv"
- "strings"
-)
-
-// Profile represents the profiling data for a specific file.
-type Profile struct {
- FileName string
- Mode string
- Blocks []ProfileBlock
-}
-
-// ProfileBlock represents a single block of profiling data.
-type ProfileBlock struct {
- StartLine, StartCol int
- EndLine, EndCol int
- NumStmt, Count int
-}
-
-type byFileName []*Profile
-
-func (p byFileName) Len() int { return len(p) }
-func (p byFileName) Less(i, j int) bool { return p[i].FileName < p[j].FileName }
-func (p byFileName) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
-
-// ParseProfiles parses profile data from the given Reader and returns a
-// Profile for each file.
-func ParseProfiles(in io.Reader) ([]*Profile, error) {
- files := make(map[string]*Profile)
- // First line is "mode: foo", where foo is "set", "count", or "atomic".
- // Rest of file is in the format
- // encoding/base64/base64.go:34.44,37.40 3 1
- // where the fields are: name.go:line.column,line.column numberOfStatements count
- s := bufio.NewScanner(in)
- mode := ""
- for s.Scan() {
- line := s.Text()
- if mode == "" {
- const p = "mode: "
- if !strings.HasPrefix(line, p) || line == p {
- return nil, fmt.Errorf("bad mode line: %v", line)
- }
- mode = line[len(p):]
- continue
- }
- m := lineRe.FindStringSubmatch(line)
- if m == nil {
- return nil, fmt.Errorf("line %q doesn't match expected format: %v", m, lineRe)
- }
- fn := m[1]
- p := files[fn]
- if p == nil {
- p = &Profile{
- FileName: fn,
- Mode: mode,
- }
- files[fn] = p
- }
- p.Blocks = append(p.Blocks, ProfileBlock{
- StartLine: toInt(m[2]),
- StartCol: toInt(m[3]),
- EndLine: toInt(m[4]),
- EndCol: toInt(m[5]),
- NumStmt: toInt(m[6]),
- Count: toInt(m[7]),
- })
- }
- if err := s.Err(); err != nil {
- return nil, err
- }
- for _, p := range files {
- sort.Sort(blocksByStart(p.Blocks))
- }
- // Generate a sorted slice.
- profiles := make([]*Profile, 0, len(files))
- for _, profile := range files {
- profiles = append(profiles, profile)
- }
- sort.Sort(byFileName(profiles))
- return profiles, nil
-}
-
-type blocksByStart []ProfileBlock
-
-func (b blocksByStart) Len() int { return len(b) }
-func (b blocksByStart) Swap(i, j int) { b[i], b[j] = b[j], b[i] }
-func (b blocksByStart) Less(i, j int) bool {
- bi, bj := b[i], b[j]
- return bi.StartLine < bj.StartLine || bi.StartLine == bj.StartLine && bi.StartCol < bj.StartCol
-}
-
-var lineRe = regexp.MustCompile(`^(.+):([0-9]+).([0-9]+),([0-9]+).([0-9]+) ([0-9]+) ([0-9]+)$`)
-
-func toInt(s string) int {
- i, err := strconv.Atoi(s)
- if err != nil {
- panic(err)
- }
- return i
-}
-
-// Boundary represents the position in a source file of the beginning or end of a
-// block as reported by the coverage profile. In HTML mode, it will correspond to
-// the opening or closing of a <span> tag and will be used to colorize the source
-type Boundary struct {
- Offset int // Location as a byte offset in the source file.
- Start bool // Is this the start of a block?
- Count int // Event count from the cover profile.
- Norm float64 // Count normalized to [0..1].
-}
-
-// Boundaries returns a Profile as a set of Boundary objects within the provided src.
-func (p *Profile) Boundaries(src []byte) (boundaries []Boundary) {
- // Find maximum count.
- max := 0
- for _, b := range p.Blocks {
- if b.Count > max {
- max = b.Count
- }
- }
- // Divisor for normalization.
- divisor := math.Log(float64(max))
-
- // boundary returns a Boundary, populating the Norm field with a normalized Count.
- boundary := func(offset int, start bool, count int) Boundary {
- b := Boundary{Offset: offset, Start: start, Count: count}
- if !start || count == 0 {
- return b
- }
- if max <= 1 {
- b.Norm = 0.8 // Profile is in"set" mode; we want a heat map. Use cov8 in the CSS.
- } else if count > 0 {
- b.Norm = math.Log(float64(count)) / divisor
- }
- return b
- }
-
- line, col := 1, 2 // TODO: Why is this 2?
- for si, bi := 0, 0; si < len(src) && bi < len(p.Blocks); {
- b := p.Blocks[bi]
- if b.StartLine == line && b.StartCol == col {
- boundaries = append(boundaries, boundary(si, true, b.Count))
- }
- if b.EndLine == line && b.EndCol == col {
- boundaries = append(boundaries, boundary(si, false, 0))
- bi++
- continue // Don't advance through src; maybe the next block starts here.
- }
- if src[si] == '\n' {
- line++
- col = 0
- }
- col++
- si++
- }
- sort.Sort(boundariesByPos(boundaries))
- return
-}
-
-type boundariesByPos []Boundary
-
-func (b boundariesByPos) Len() int { return len(b) }
-func (b boundariesByPos) Swap(i, j int) { b[i], b[j] = b[j], b[i] }
-func (b boundariesByPos) Less(i, j int) bool {
- if b[i].Offset == b[j].Offset {
- return !b[i].Start && b[j].Start
- }
- return b[i].Offset < b[j].Offset
-}
-
-// findFile finds the location of the named file in GOROOT, GOPATH etc.
-func findFile(file string) (string, error) {
- if strings.HasPrefix(file, "_") {
- file = file[1:]
- }
- if _, err := os.Stat(file); err == nil {
- return file, nil
- }
- dir, file := filepath.Split(file)
- pkg, err := build.Import(dir, ".", build.FindOnly)
- if err != nil {
- return "", fmt.Errorf("can't find %q: %v", file, err)
- }
- return filepath.Join(pkg.Dir, file), nil
-}