mirror of
https://gitlab.com/pulsechaincom/go-pulse.git
synced 2024-12-25 04:47:17 +00:00
289b30715d
This commit converts the dependency management from Godeps to the vendor folder, also switching the tool from godep to trash. Since the upstream tool lacks a few features proposed via a few PRs, until those PRs are merged in (if), use github.com/karalabe/trash. You can update dependencies via trash --update. All dependencies have been updated to their latest version. Parts of the build system are reworked to drop old notions of Godeps and invocation of the go vet command so that it doesn't run against the vendor folder, as that will just blow up during vetting. The conversion drops OpenCL (and hence GPU mining support) from ethash and our codebase. The short reasoning is that there's noone to maintain and having opencl libs in our deps messes up builds as go install ./... tries to build them, failing with unsatisfied link errors for the C OpenCL deps. golang.org/x/net/context is not vendored in. We expect it to be fetched by the user (i.e. using go get). To keep ci.go builds reproducible the package is "vendored" in build/_vendor.
89 lines
2.1 KiB
Go
89 lines
2.1 KiB
Go
package check
|
|
|
|
import (
|
|
"fmt"
|
|
"io"
|
|
"sync"
|
|
)
|
|
|
|
// -----------------------------------------------------------------------
|
|
// Output writer manages atomic output writing according to settings.
|
|
|
|
type outputWriter struct {
|
|
m sync.Mutex
|
|
writer io.Writer
|
|
wroteCallProblemLast bool
|
|
Stream bool
|
|
Verbose bool
|
|
}
|
|
|
|
func newOutputWriter(writer io.Writer, stream, verbose bool) *outputWriter {
|
|
return &outputWriter{writer: writer, Stream: stream, Verbose: verbose}
|
|
}
|
|
|
|
func (ow *outputWriter) Write(content []byte) (n int, err error) {
|
|
ow.m.Lock()
|
|
n, err = ow.writer.Write(content)
|
|
ow.m.Unlock()
|
|
return
|
|
}
|
|
|
|
func (ow *outputWriter) WriteCallStarted(label string, c *C) {
|
|
if ow.Stream {
|
|
header := renderCallHeader(label, c, "", "\n")
|
|
ow.m.Lock()
|
|
ow.writer.Write([]byte(header))
|
|
ow.m.Unlock()
|
|
}
|
|
}
|
|
|
|
func (ow *outputWriter) WriteCallProblem(label string, c *C) {
|
|
var prefix string
|
|
if !ow.Stream {
|
|
prefix = "\n-----------------------------------" +
|
|
"-----------------------------------\n"
|
|
}
|
|
header := renderCallHeader(label, c, prefix, "\n\n")
|
|
ow.m.Lock()
|
|
ow.wroteCallProblemLast = true
|
|
ow.writer.Write([]byte(header))
|
|
if !ow.Stream {
|
|
c.logb.WriteTo(ow.writer)
|
|
}
|
|
ow.m.Unlock()
|
|
}
|
|
|
|
func (ow *outputWriter) WriteCallSuccess(label string, c *C) {
|
|
if ow.Stream || (ow.Verbose && c.kind == testKd) {
|
|
// TODO Use a buffer here.
|
|
var suffix string
|
|
if c.reason != "" {
|
|
suffix = " (" + c.reason + ")"
|
|
}
|
|
if c.status() == succeededSt {
|
|
suffix += "\t" + c.timerString()
|
|
}
|
|
suffix += "\n"
|
|
if ow.Stream {
|
|
suffix += "\n"
|
|
}
|
|
header := renderCallHeader(label, c, "", suffix)
|
|
ow.m.Lock()
|
|
// Resist temptation of using line as prefix above due to race.
|
|
if !ow.Stream && ow.wroteCallProblemLast {
|
|
header = "\n-----------------------------------" +
|
|
"-----------------------------------\n" +
|
|
header
|
|
}
|
|
ow.wroteCallProblemLast = false
|
|
ow.writer.Write([]byte(header))
|
|
ow.m.Unlock()
|
|
}
|
|
}
|
|
|
|
func renderCallHeader(label string, c *C, prefix, suffix string) string {
|
|
pc := c.method.PC()
|
|
return fmt.Sprintf("%s%s: %s: %s%s", prefix, label, niceFuncPath(pc),
|
|
niceFuncName(pc), suffix)
|
|
}
|