Skip to content

Commit

Permalink
test: make test prereqs like Docker, plugins, etc. opt-in
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
guseggert authored and hacdias committed Apr 5, 2023
1 parent f5bcaae commit 908b673
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 28 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/gobuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
4 changes: 2 additions & 2 deletions .github/workflows/golint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/gotest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/sharness.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion coverage/Rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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 -) > $@

Expand Down
6 changes: 3 additions & 3 deletions test/cli/testutils/requires.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
Expand All @@ -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()
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/sharness/Rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions test/sharness/lib/test-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand Down

0 comments on commit 908b673

Please sign in to comment.