From 908b6730c691752cb0ff7822a0470c8868fc1215 Mon Sep 17 00:00:00 2001 From: Gus Eggert Date: Fri, 17 Mar 2023 10:24:17 -0400 Subject: [PATCH] test: make test prereqs like Docker, plugins, etc. opt-in This is so that by default, you can run tests without having to set up any of these things and without having to set env vars on the test runner. This makes it easier to run the CLI tests in your IDE without having to setup special env vars to skip the Docker, plugin, and fuse tests. --- .github/workflows/build.yml | 12 ++++++------ .github/workflows/gobuild.yml | 6 +++--- .github/workflows/golint.yml | 4 ++-- .github/workflows/gotest.yml | 4 ++-- .github/workflows/sharness.yml | 6 +++--- Rules.mk | 2 +- coverage/Rules.mk | 2 +- test/cli/testutils/requires.go | 6 +++--- test/sharness/Rules.mk | 2 +- test/sharness/lib/test-lib.sh | 12 ++++++------ 10 files changed, 28 insertions(+), 28 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ddb3382c6999..50889613bea2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -20,8 +20,8 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 5 env: - TEST_NO_DOCKER: 1 - TEST_NO_FUSE: 1 + TEST_DOCKER: 0 + TEST_FUSE: 0 TEST_VERBOSE: 1 TRAVIS: 1 GIT_PAGER: cat @@ -86,8 +86,8 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 5 env: - TEST_NO_DOCKER: 1 - TEST_NO_FUSE: 1 + TEST_DOCKER: 0 + TEST_FUSE: 0 TEST_VERBOSE: 1 TRAVIS: 1 GIT_PAGER: cat @@ -126,8 +126,8 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 5 env: - TEST_NO_DOCKER: 1 - TEST_NO_FUSE: 1 + TEST_DOCKER: 0 + TEST_FUSE: 0 TEST_VERBOSE: 1 TRAVIS: 1 GIT_PAGER: cat diff --git a/.github/workflows/gobuild.yml b/.github/workflows/gobuild.yml index 26dc66777f37..f1e3a60b7767 100644 --- a/.github/workflows/gobuild.yml +++ b/.github/workflows/gobuild.yml @@ -20,7 +20,7 @@ jobs: runs-on: ${{ fromJSON(needs.go-build-runner.outputs.config).labels }} timeout-minutes: 20 env: - TEST_NO_DOCKER: 1 + TEST_DOCKER: 0 TEST_VERBOSE: 1 TRAVIS: 1 GIT_PAGER: cat @@ -38,7 +38,7 @@ jobs: name: ${{ github.job }} - run: make cmd/ipfs-try-build env: - TEST_NO_FUSE: 0 + TEST_FUSE: 1 - run: make cmd/ipfs-try-build env: - TEST_NO_FUSE: 1 + TEST_FUSE: 0 diff --git a/.github/workflows/golint.yml b/.github/workflows/golint.yml index ae3683ff49bf..216573a468e5 100644 --- a/.github/workflows/golint.yml +++ b/.github/workflows/golint.yml @@ -17,8 +17,8 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 10 env: - TEST_NO_DOCKER: 1 - TEST_NO_FUSE: 1 + TEST_DOCKER: 0 + TEST_FUSE: 0 TEST_VERBOSE: 1 TRAVIS: 1 GIT_PAGER: cat diff --git a/.github/workflows/gotest.yml b/.github/workflows/gotest.yml index ab35ec3a7980..81c39fd5e51a 100644 --- a/.github/workflows/gotest.yml +++ b/.github/workflows/gotest.yml @@ -20,8 +20,8 @@ jobs: runs-on: ${{ fromJSON(needs.go-test-runner.outputs.config).labels }} timeout-minutes: 20 env: - TEST_NO_DOCKER: 1 - TEST_NO_FUSE: 1 + TEST_DOCKER: 0 + TEST_FUSE: 0 TEST_VERBOSE: 1 TRAVIS: 1 GIT_PAGER: cat diff --git a/.github/workflows/sharness.yml b/.github/workflows/sharness.yml index 04779d15f40e..012a6a9826ed 100644 --- a/.github/workflows/sharness.yml +++ b/.github/workflows/sharness.yml @@ -49,9 +49,9 @@ jobs: test/sharness/test-results/sharness.xml working-directory: kubo env: - TEST_NO_DOCKER: 0 - TEST_NO_PLUGIN: 1 - TEST_NO_FUSE: 1 + TEST_DOCKER: 1 + TEST_PLUGIN: 0 + TEST_FUSE: 0 TEST_VERBOSE: 1 TEST_JUNIT: 1 TEST_EXPENSIVE: 1 diff --git a/Rules.mk b/Rules.mk index 3d3d9c13951c..cec34cef7f7a 100644 --- a/Rules.mk +++ b/Rules.mk @@ -19,7 +19,7 @@ include mk/golang.mk # extra properties # # -------------------- # -ifeq ($(TEST_NO_FUSE),1) +ifeq ($(TEST_FUSE),0) GOTAGS += nofuse endif export LIBP2P_TCP_REUSEPORT=false diff --git a/coverage/Rules.mk b/coverage/Rules.mk index 7770ed69b5d0..48fce28568c4 100644 --- a/coverage/Rules.mk +++ b/coverage/Rules.mk @@ -45,7 +45,7 @@ endif export IPFS_COVER_DIR:= $(realpath $(d))/sharnesscover/ -$(d)/sharness_tests.coverprofile: export TEST_NO_PLUGIN=1 +$(d)/sharness_tests.coverprofile: export TEST_PLUGIN=0 $(d)/sharness_tests.coverprofile: $(d)/ipfs cmd/ipfs/ipfs-test-cover $(d)/coverage_deps test_sharness (cd $(@D)/sharnesscover && find . -type f | gocovmerge -list -) > $@ diff --git a/test/cli/testutils/requires.go b/test/cli/testutils/requires.go index d4b88cd6dfed..1462b7fee905 100644 --- a/test/cli/testutils/requires.go +++ b/test/cli/testutils/requires.go @@ -7,13 +7,13 @@ import ( ) func RequiresDocker(t *testing.T) { - if os.Getenv("TEST_NO_DOCKER") == "1" { + if os.Getenv("TEST_DOCKER") != "1" { t.SkipNow() } } func RequiresFUSE(t *testing.T) { - if os.Getenv("TEST_NO_FUSE") == "1" { + if os.Getenv("TEST_FUSE") != "1" { t.SkipNow() } } @@ -25,7 +25,7 @@ func RequiresExpensive(t *testing.T) { } func RequiresPlugins(t *testing.T) { - if os.Getenv("TEST_NO_PLUGIN") == "1" { + if os.Getenv("TEST_PLUGIN") != "1" { t.SkipNow() } } diff --git a/test/sharness/Rules.mk b/test/sharness/Rules.mk index f95aee15e0dc..0dcd8d2e4aef 100644 --- a/test/sharness/Rules.mk +++ b/test/sharness/Rules.mk @@ -21,7 +21,7 @@ $(PLUGINS_$(d)): $(ORGIN_PLUGINS_$(d)) @mkdir -p $(@D) cp -f plugin/plugins/$(@F) $@ -ifneq ($(TEST_NO_PLUGIN),1) +ifneq ($(TEST_PLUGIN),0) DEPS_$(d) += $(PLUGINS_$(d)) endif endif diff --git a/test/sharness/lib/test-lib.sh b/test/sharness/lib/test-lib.sh index f135cdd7940e..bd8f7de9b90b 100644 --- a/test/sharness/lib/test-lib.sh +++ b/test/sharness/lib/test-lib.sh @@ -94,10 +94,10 @@ export TERM=dumb TEST_OS="$(uname -s | tr '[a-z]' '[A-Z]')" # grab + output options -test "$TEST_NO_FUSE" != 1 && test_set_prereq FUSE +test "$TEST_FUSE" = 1 && test_set_prereq FUSE test "$TEST_EXPENSIVE" = 1 && test_set_prereq EXPENSIVE -test "$TEST_NO_DOCKER" != 1 && type docker >/dev/null 2>&1 && groups | egrep "\bdocker\b" && test_set_prereq DOCKER -test "$TEST_NO_PLUGIN" != 1 && test "$TEST_OS" = "LINUX" && test_set_prereq PLUGIN +test "$TEST_DOCKER" = 1 && type docker >/dev/null 2>&1 && groups | egrep "\bdocker\b" && test_set_prereq DOCKER +test "$TEST_PLUGIN" = 1 && test "$TEST_OS" = "LINUX" && test_set_prereq PLUGIN # this may not be available, skip a few dependent tests type socat >/dev/null 2>&1 && test_set_prereq SOCAT @@ -110,9 +110,9 @@ expr "$TEST_OS" : "CYGWIN_NT" >/dev/null || test_set_prereq STD_ERR_MSG if test "$TEST_VERBOSE" = 1; then echo '# TEST_VERBOSE='"$TEST_VERBOSE" echo '# TEST_IMMEDIATE='"$TEST_IMMEDIATE" - echo '# TEST_NO_FUSE='"$TEST_NO_FUSE" - echo '# TEST_NO_DOCKER='"$TEST_NO_DOCKER" - echo '# TEST_NO_PLUGIN='"$TEST_NO_PLUGIN" + echo '# TEST_FUSE='"$TEST_FUSE" + echo '# TEST_DOCKER='"$TEST_DOCKER" + echo '# TEST_PLUGIN='"$TEST_PLUGIN" echo '# TEST_EXPENSIVE='"$TEST_EXPENSIVE" echo '# TEST_OS='"$TEST_OS" echo '# TEST_JUNIT='"$TEST_JUNIT"