Skip to content

Commit

Permalink
plugin: add sharness tests
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Łukasz Magiera <[email protected]>
  • Loading branch information
magik6k committed Oct 17, 2017
1 parent 9ee628d commit cdbfbb4
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 11 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ PROTOC = protoc --gogo_out=. --proto_path=.:/usr/local/opt/protobuf/include:$(di
# enable second expansion
.SECONDEXPANSION:

include config.mk
include Rules.mk
8 changes: 4 additions & 4 deletions cmd/ipfs/Rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ PATH := $(realpath $(d)):$(PATH)
# DEPS_OO_$(d) += merkledag/pb/merkledag.pb.go namesys/pb/namesys.pb.go
# DEPS_OO_$(d) += pin/internal/pb/header.pb.go unixfs/pb/unixfs.pb.go

CONFIG_COMMIT ?= github.com/ipfs/go-ipfs/repo/config.CurrentCommit=$(shell git rev-parse --short HEAD)
CONFIG_PLUGIN_PATH ?= github.com/ipfs/go-ipfs/repo/config.SystemPluginPath=${PLUGIN_PATH}

$(d)_flags =-ldflags="-X ${CONFIG_COMMIT} -X ${CONFIG_PLUGIN_PATH}"
$(d)_flags =-ldflags="
$(d)_flags += -X github.com/ipfs/go-ipfs/repo/config.CurrentCommit=${CONFIG_COMMIT}
$(d)_flags += -X github.com/ipfs/go-ipfs/repo/config.SystemPluginPath=${CONFIG_PLUGIN_PATH}
$(d)_flags += "

$(IPFS_BIN_$(d)): GOFLAGS += $(cmd/ipfs_flags)

Expand Down
2 changes: 2 additions & 0 deletions config.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CONFIG_COMMIT := $(shell git rev-parse --short HEAD)
CONFIG_PLUGIN_PATH = ${PLUGIN_PATH}
7 changes: 5 additions & 2 deletions test/sharness/Rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ T_$(d) = $(sort $(wildcard $(d)/t[0-9][0-9][0-9][0-9]-*.sh))
DEPS_$(d) := test/bin/random test/bin/multihash test/bin/pollEndpoint \
test/bin/iptb test/bin/go-sleep test/bin/random-files \
test/bin/go-timeout test/bin/hang-fds test/bin/ma-pipe-unidir
DEPS_$(d) += cmd/ipfs/ipfs
DEPS_$(d) += $(d)/clean-test-results
DEPS_$(d) += $(SHARNESS_$(d))
DEPS_$(d) += $(d)/sharness-ipfs

ifeq ($(OS),Linux)
PLUGINS_DIR_$(d) := $(d)/plugins/
Expand Down Expand Up @@ -49,13 +49,16 @@ $(SHARNESS_$(d)): $(d) ALWAYS
$(d)/deps: $(SHARNESS_$(d)) $$(DEPS_$(d)) # use second expansion so coverage can inject dependency
.PHONY: $(d)/deps

$(d)/sharness-ipfs: PLUGIN_PATH=./system_plugins
$(d)/sharness-ipfs: cmd/ipfs/ipfs
.PHONY: $(d)/sharness-ipfs

test_sharness_deps: $(d)/deps
.PHONY: test_sharness_deps

test_sharness_short: $(d)/aggregate
.PHONY: test_sharness_short


test_sharness_expensive: export TEST_EXPENSIVE=1
test_sharness_expensive: test_sharness_short
.PHONY: test_sharness_expensive
Expand Down
32 changes: 27 additions & 5 deletions test/sharness/t0280-plugin-git.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ fi

test_init_ipfs

test_expect_success "copy plugin" '
mkdir -p "$IPFS_PATH/plugins" &&
cp ../plugins/git.so "$IPFS_PATH/plugins/"
'

# from https://github.com/ipfs/go-ipld-git/blob/master/make-test-repo.sh
test_expect_success "prepare test data" '
tar xzf ../t0280-plugin-git-data/git.tar.gz
Expand All @@ -46,6 +41,33 @@ test_dag_git() {
'
}

test_expect_success "copy plugin to local plugin directory" '
mkdir -p "$IPFS_PATH/plugins" &&
chmod +x ../plugins/git.so &&
cp ../plugins/git.so "$IPFS_PATH/plugins/"
'

# should work offline
#test_dag_git

# should work online
test_launch_ipfs_daemon
test_dag_git
test_kill_ipfs_daemon

test_expect_success "copy plugin to global plugin directory" '
mkdir -p "./system_plugins" &&
cp ../plugins/git.so "./system_plugins/"
'

test_expect_success "fail with duplicate plugin" '
echo 123 | test_must_fail ipfs dag put
'

test_expect_success "remove local plugin" '
rm -r "$IPFS_PATH/plugins/"
'

# should work offline
#test_dag_git

Expand Down

0 comments on commit cdbfbb4

Please sign in to comment.