Merge from yung stanley's master branch

Signed-off-by: kayos@tcp.direct <kayos@tcp.direct>
This commit is contained in:
kayos@tcp.direct 2022-03-21 17:06:14 -07:00
commit 4be5266426
Signed by: kayos
GPG Key ID: 4B841471B4BEE979
8 changed files with 47 additions and 52 deletions

23
.github/workflows/test.yml vendored Normal file

@ -0,0 +1,23 @@
name: test
on:
push: {}
pull_request: { branches: [master] }
jobs:
test:
runs-on: ubuntu-latest
steps:
- id: goversion
run: |
echo ::set-output name=version::$(curl -s https://raw.githubusercontent.com/actions/go-versions/main/versions-manifest.json | sed -rn 's/.*"version": "([0-9]\.[0-9]+(\.[0-9]+)?)".*/\1/p' | head -1)
- uses: actions/setup-go@v2
with: { go-version: "${{ steps.goversion.outputs.version }}" }
- uses: actions/checkout@v2
- run: |
go install golang.org/x/lint/golint@latest
- run: $(go env GOPATH)/bin/golint -min_confidence 0.9 -set_exit_status
- run: |
GORACE="exitcode=1 halt_on_error=1" go test -v -coverprofile=coverage.txt -race -timeout 3m -count 3 -cpu 1,4
bash <(curl -s https://codecov.io/bash)
- run: go vet -v .

@ -576,6 +576,7 @@ func handleNAMES(c *Client, e Event) {
var modes, nick string
var ok bool
var s *Source
for i := 0; i < len(parts); i++ {
modes, nick, ok = parseUserPrefix(parts[i])

@ -120,7 +120,6 @@ func handleSASL(c *Client, e Event) {
break
}
}
return
}
func handleSASLError(c *Client, e Event) {

@ -43,7 +43,6 @@ type ircConn struct {
// lastPong is the last successful time that we pinged the server and
// received a successful pong back.
lastPong atomic.Value
// pingDelay time.Duration
}
// Dialer is an interface implementation of net.Dialer. Use this if you would
@ -275,7 +274,6 @@ func (c *Client) MockConnect(conn net.Conn) error {
func (c *Client) internalConnect(mock net.Conn, dialer Dialer) error {
startConn:
if c.conn != nil {
panic("use of connect more than once")
}
@ -614,13 +612,18 @@ func (c *Client) pingLoop(ctx context.Context, errs chan error, working *int32)
if time.Since(c.conn.lastPong.Load().(time.Time)) > c.Config.PingDelay+(120*time.Second) {
// It's 60 seconds over what out ping delay is, connection
// has probably dropped.
errs <- ErrTimedOut{
err := ErrTimedOut{
TimeSinceSuccess: time.Since(c.conn.lastPong.Load().(time.Time)),
LastPong: c.conn.lastPong.Load().(time.Time),
LastPing: c.conn.lastPing.Load().(time.Time),
Delay: c.Config.PingDelay,
}
go func() {
errs <- err
}()
wg.Done()
return
}

@ -48,8 +48,6 @@ func TestDecode(t *testing.T) {
if err == nil {
t.Fatalf("should have failed to parse decoded event. got: %#v", event)
}
return
}
func TestEncode(t *testing.T) {
@ -72,8 +70,6 @@ func TestEncode(t *testing.T) {
if want != line {
t.Fatalf("encoded line wanted: %q, got: %q", want, line)
}
return
}
func TestRate(t *testing.T) {
@ -90,8 +86,6 @@ func TestRate(t *testing.T) {
if delay := c.rate(200); delay > (3 * time.Second) {
t.Fatal("rate delay too high")
}
return
}
func genMockConn() (client *Client, clientConn net.Conn, serverConn net.Conn) {

@ -348,6 +348,7 @@ const (
RPL_LOCALUSERS = "265" // aircd/hybrid/bahamut, used on freenode.
RPL_TOPICWHOTIME = "333" // ircu, used on freenode.
RPL_WHOSPCRPL = "354" // ircu, used on networks with WHOX support.
RPL_CREATIONTIME = "329"
)
// As seen in the wild.

@ -13,32 +13,24 @@ func BenchmarkFormat(b *testing.B) {
for i := 0; i < b.N; i++ {
Fmt("{red}test{c}")
}
return
}
func BenchmarkFormatLong(b *testing.B) {
for i := 0; i < b.N; i++ {
Fmt("{red}test {blue}2 {red}3 {brown} {italic}test{c}")
}
return
}
func BenchmarkStripFormat(b *testing.B) {
for i := 0; i < b.N; i++ {
TrimFmt("{red}test{c}")
}
return
}
func BenchmarkStripFormatLong(b *testing.B) {
for i := 0; i < b.N; i++ {
TrimFmt("{red}test {blue}2 {red}3 {brown} {italic}test{c}")
}
return
}
func BenchmarkStripRaw(b *testing.B) {
@ -46,8 +38,6 @@ func BenchmarkStripRaw(b *testing.B) {
for i := 0; i < b.N; i++ {
StripRaw(text)
}
return
}
func BenchmarkStripRawLong(b *testing.B) {
@ -55,8 +45,6 @@ func BenchmarkStripRawLong(b *testing.B) {
for i := 0; i < b.N; i++ {
StripRaw(text)
}
return
}
func TestFormat(t *testing.T) {
@ -249,8 +237,6 @@ func TestToRFC1459(t *testing.T) {
t.Errorf("ToRFC1459() = %q, want %q", got, tt.want)
}
}
return
}
//func BenchmarkGlob(b *testing.B) {
@ -267,23 +253,17 @@ func testGlobMatch(t *testing.T, subj, pattern string) {
if !Glob(subj, pattern) {
t.Fatalf("'%s' should match '%s'", pattern, subj)
}
return
}
func testGlobNoMatch(t *testing.T, subj, pattern string) {
if Glob(subj, pattern) {
t.Fatalf("'%s' should not match '%s'", pattern, subj)
}
return
}
func TestEmptyPattern(t *testing.T) {
testGlobMatch(t, "", "")
testGlobNoMatch(t, "test", "")
return
}
func TestEmptySubject(t *testing.T) {
@ -324,14 +304,10 @@ func TestEmptySubject(t *testing.T) {
for _, pattern := range cases {
testGlobNoMatch(t, pattern, "")
}
return
}
func TestPatternWithoutGlobs(t *testing.T) {
testGlobMatch(t, "test", "test")
return
}
func TestGlob(t *testing.T) {
@ -368,6 +344,4 @@ func TestGlob(t *testing.T) {
for _, pattern := range cases {
testGlobNoMatch(t, "this is a test", pattern)
}
return
}