Skip to content

Commit

Permalink
testutils/docker: remove use of docker gotag
Browse files Browse the repository at this point in the history
The `docker` tag here doesn't seem to serve any purpose besides
preventing the test from being run by `go test ./...`. Instead, we
simply skip the test if it's not built with Bazel.

Closes #123265.

Epic: None
Release note: None
  • Loading branch information
rickystewart committed Apr 30, 2024
1 parent 4a70296 commit 8c51559
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 21 deletions.
5 changes: 2 additions & 3 deletions pkg/testutils/docker/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

# keep
go_test(
name = "docker_test",
srcs = ["single_node_docker_test.go"],
data = glob(["testdata/**"]) + [
"//pkg/testutils/docker:testdata",
"//pkg/testutils/docker/docker-fsnotify",
],
gotags = ["docker"],
tags = [
"integration",
"no-remote-exec",
],
deps = [
"//pkg/util/ctxlog",
"//pkg/build/bazel",
"//pkg/testutils/skip",
"//pkg/util/log",
"//pkg/util/timeutil",
"@com_github_cockroachdb_errors//:errors",
Expand Down
13 changes: 0 additions & 13 deletions pkg/testutils/docker/empty.go

This file was deleted.

15 changes: 10 additions & 5 deletions pkg/testutils/docker/single_node_docker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
// by the Apache License, Version 2.0, included in the file
// licenses/APL.txt.

//go:build docker
// +build docker

package docker

import (
Expand All @@ -21,12 +18,13 @@ import (
"io"
"math"
"os"
"path/filepath"
"strconv"
"strings"
"testing"
"time"

"github.com/cockroachdb/cockroach/pkg/build/bazel"
"github.com/cockroachdb/cockroach/pkg/testutils/skip"
"github.com/cockroachdb/cockroach/pkg/util/log"
"github.com/cockroachdb/cockroach/pkg/util/timeutil"
"github.com/cockroachdb/errors"
Expand Down Expand Up @@ -75,7 +73,14 @@ func TestSingleNodeDocker(t *testing.T) {
t.Fatal(errors.NewAssertionErrorWithWrappedErrf(err, "cannot get pwd"))
}

fsnotifyBinPath := filepath.Join(pwd, "docker-fsnotify/docker-fsnotify-bin")
if !bazel.BuiltWithBazel() {
skip.IgnoreLint(t)
}

fsnotifyBinPath, err := bazel.Runfile("pkg/testutils/docker/docker-fsnotify/docker-fsnotify-bin")
if err != nil {
t.Fatal(err)
}

var dockerTests = []singleNodeDockerTest{
{
Expand Down
2 changes: 2 additions & 0 deletions pkg/testutils/lint/lint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2010,6 +2010,8 @@ func TestLint(t *testing.T) {
// times and merging the results: https://staticcheck.io/docs/running-staticcheck/cli/build-tags/
// This is more trouble than it's worth right now.
stream.GrepNot(`pkg/cmd/mirror/go/mirror.go`),
// As above, the bazel build tag has an impact here.
stream.GrepNot(`pkg/testutils/docker/single_node_docker_test.go`),
}
for analyzerName, config := range nogoConfig {
if !staticcheckCheckNameRe.MatchString(analyzerName) {
Expand Down

0 comments on commit 8c51559

Please sign in to comment.