From 37ce0bab8c7afe5133b33bb44cff06fe965cf109 Mon Sep 17 00:00:00 2001 From: Daniel Swarbrick Date: Tue, 15 Aug 2023 11:38:13 +0200 Subject: [PATCH] Sync build tags in *_test.go (#2767) Ensure that unwanted tests are correctly excluded when various build tags are specified, i.e. when the code that they test would be excluded from compilation. Signed-off-by: Daniel Swarbrick --- collector/bonding_linux_test.go | 3 +++ collector/diskstats_linux_test.go | 3 +++ collector/ethtool_linux_test.go | 3 +++ collector/filefd_linux_test.go | 3 +++ collector/filesystem_linux_test.go | 5 ++++- collector/interrupts_linux_test.go | 3 +++ collector/ipvs_linux_test.go | 3 +++ collector/loadavg_linux_test.go | 3 +++ collector/logind_linux_test.go | 3 +++ collector/meminfo_linux_test.go | 3 +++ collector/meminfo_numa_linux_test.go | 3 +++ collector/netdev_linux_test.go | 3 +++ collector/netstat_linux_test.go | 3 +++ collector/perf_linux_test.go | 5 ++--- collector/systemd_linux_test.go | 3 +++ collector/tcpstat_linux_test.go | 3 +++ collector/textfile_test.go | 3 +++ 17 files changed, 51 insertions(+), 4 deletions(-) diff --git a/collector/bonding_linux_test.go b/collector/bonding_linux_test.go index 564cf01e..98af73fa 100644 --- a/collector/bonding_linux_test.go +++ b/collector/bonding_linux_test.go @@ -11,6 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build !nobonding +// +build !nobonding + package collector import ( diff --git a/collector/diskstats_linux_test.go b/collector/diskstats_linux_test.go index 526b25d6..f0d7499b 100644 --- a/collector/diskstats_linux_test.go +++ b/collector/diskstats_linux_test.go @@ -11,6 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build !nodiskstats +// +build !nodiskstats + package collector import ( diff --git a/collector/ethtool_linux_test.go b/collector/ethtool_linux_test.go index 761351c6..cf55c6b1 100644 --- a/collector/ethtool_linux_test.go +++ b/collector/ethtool_linux_test.go @@ -11,6 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build !noethtool +// +build !noethtool + package collector import ( diff --git a/collector/filefd_linux_test.go b/collector/filefd_linux_test.go index 37e16a4e..f31a5c2c 100644 --- a/collector/filefd_linux_test.go +++ b/collector/filefd_linux_test.go @@ -11,6 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build !nofilefd +// +build !nofilefd + package collector import "testing" diff --git a/collector/filesystem_linux_test.go b/collector/filesystem_linux_test.go index 4705630d..325ffc87 100644 --- a/collector/filesystem_linux_test.go +++ b/collector/filesystem_linux_test.go @@ -11,14 +11,17 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build !nofilesystem +// +build !nofilesystem + package collector import ( - "github.com/go-kit/log" "strings" "testing" "github.com/alecthomas/kingpin/v2" + "github.com/go-kit/log" ) func Test_parseFilesystemLabelsError(t *testing.T) { diff --git a/collector/interrupts_linux_test.go b/collector/interrupts_linux_test.go index 01898368..82e536e4 100644 --- a/collector/interrupts_linux_test.go +++ b/collector/interrupts_linux_test.go @@ -11,6 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build !nointerrupts +// +build !nointerrupts + package collector import ( diff --git a/collector/ipvs_linux_test.go b/collector/ipvs_linux_test.go index 8c43ad8b..6ee41b29 100644 --- a/collector/ipvs_linux_test.go +++ b/collector/ipvs_linux_test.go @@ -11,6 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build !noipvs +// +build !noipvs + package collector import ( diff --git a/collector/loadavg_linux_test.go b/collector/loadavg_linux_test.go index e8e5a0ce..2d56317d 100644 --- a/collector/loadavg_linux_test.go +++ b/collector/loadavg_linux_test.go @@ -11,6 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build !noloadavg +// +build !noloadavg + package collector import "testing" diff --git a/collector/logind_linux_test.go b/collector/logind_linux_test.go index e8d9cb02..5cfedff4 100644 --- a/collector/logind_linux_test.go +++ b/collector/logind_linux_test.go @@ -11,6 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build !nologind +// +build !nologind + package collector import ( diff --git a/collector/meminfo_linux_test.go b/collector/meminfo_linux_test.go index dc0aff58..a000bea5 100644 --- a/collector/meminfo_linux_test.go +++ b/collector/meminfo_linux_test.go @@ -11,6 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build !nomeminfo +// +build !nomeminfo + package collector import ( diff --git a/collector/meminfo_numa_linux_test.go b/collector/meminfo_numa_linux_test.go index a17714e8..33bc362e 100644 --- a/collector/meminfo_numa_linux_test.go +++ b/collector/meminfo_numa_linux_test.go @@ -11,6 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build !nomeminfo_numa +// +build !nomeminfo_numa + package collector import ( diff --git a/collector/netdev_linux_test.go b/collector/netdev_linux_test.go index ff5e1c22..7909d018 100644 --- a/collector/netdev_linux_test.go +++ b/collector/netdev_linux_test.go @@ -11,6 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build !nonetdev +// +build !nonetdev + package collector import ( diff --git a/collector/netstat_linux_test.go b/collector/netstat_linux_test.go index a27382b4..ec430bc3 100644 --- a/collector/netstat_linux_test.go +++ b/collector/netstat_linux_test.go @@ -11,6 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build !nonetstat +// +build !nonetstat + package collector import ( diff --git a/collector/perf_linux_test.go b/collector/perf_linux_test.go index c4990d77..fc557ffd 100644 --- a/collector/perf_linux_test.go +++ b/collector/perf_linux_test.go @@ -11,8 +11,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -//go:build !noprocesses -// +build !noprocesses +//go:build !noperf +// +build !noperf package collector @@ -24,7 +24,6 @@ import ( "testing" "github.com/go-kit/log" - "github.com/prometheus/client_golang/prometheus" ) diff --git a/collector/systemd_linux_test.go b/collector/systemd_linux_test.go index 86573d2a..d4e300d1 100644 --- a/collector/systemd_linux_test.go +++ b/collector/systemd_linux_test.go @@ -11,6 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build !nosystemd +// +build !nosystemd + package collector import ( diff --git a/collector/tcpstat_linux_test.go b/collector/tcpstat_linux_test.go index 693f04fe..e1bd090a 100644 --- a/collector/tcpstat_linux_test.go +++ b/collector/tcpstat_linux_test.go @@ -11,6 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build !notcpstat +// +build !notcpstat + package collector import ( diff --git a/collector/textfile_test.go b/collector/textfile_test.go index d759dfaf..95e5966f 100644 --- a/collector/textfile_test.go +++ b/collector/textfile_test.go @@ -11,6 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build !notextfile +// +build !notextfile + package collector import (