Skip to content

Commit 66a2ffd

Browse files
committed
use env instead of build directive to skip integration tests
1 parent 2bde28c commit 66a2ffd

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,4 @@ test:
3939

4040
.PHONY: test-integration
4141
test-integration:
42-
go test -v -count=1 -tags=integration ./integration/
42+
CODER_TEST_INTEGRATION=1 go test -v -count=1 ./integration/

integration/docker_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
//go:build integration
2-
// +build integration
3-
41
package integration_test
52

63
import (
@@ -24,6 +21,9 @@ import (
2421

2522
func TestDocker(t *testing.T) {
2623
t.Parallel()
24+
if val, ok := os.LookupEnv("CODER_TEST_INTEGRATION"); !ok || val != "1" {
25+
t.Skip("integration tests are skipped unless CODER_TEST_INTEGRATION=true")
26+
}
2727

2828
// Dockerd just tests that dockerd can spin up and function correctly.
2929
t.Run("Dockerd", func(t *testing.T) {

integration/gpu_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package integration
22

33
import (
44
"context"
5+
"os"
56
"os/exec"
67
"slices"
78
"strings"
@@ -14,6 +15,10 @@ import (
1415
)
1516

1617
func TestDocker_Nvidia(t *testing.T) {
18+
t.Parallel()
19+
if val, ok := os.LookupEnv("CODER_TEST_INTEGRATION"); !ok || val != "1" {
20+
t.Skip("integration tests are skipped unless CODER_TEST_INTEGRATION=true")
21+
}
1722
// Only run this test if the nvidia container runtime is detected.
1823
// Check if the nvidia runtime is available using `docker info`.
1924
// The docker client doesn't expose this information so we need to fetch it ourselves.
@@ -22,6 +27,7 @@ func TestDocker_Nvidia(t *testing.T) {
2227
}
2328

2429
t.Run("Ubuntu", func(t *testing.T) {
30+
t.Parallel()
2531
ctx, cancel := context.WithCancel(context.Background())
2632
t.Cleanup(cancel)
2733

@@ -39,6 +45,7 @@ func TestDocker_Nvidia(t *testing.T) {
3945
})
4046

4147
t.Run("Redhat", func(t *testing.T) {
48+
t.Parallel()
4249
ctx, cancel := context.WithCancel(context.Background())
4350
t.Cleanup(cancel)
4451

0 commit comments

Comments
 (0)