diff --git a/Makefile b/Makefile index 9f5e509d60c7f6ca9fd3826e132b8598aa4917c2..629ed12e1b73df545d44cf2fd476ae6a95cca356 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/cmd/ipfs/Rules.mk b/cmd/ipfs/Rules.mk index 8c9a15a869267b2dfb47d3990aa79f24033a2a77..40cee7a87f8ecb557a84024f74e85b3509921fc4 100644 --- a/cmd/ipfs/Rules.mk +++ b/cmd/ipfs/Rules.mk @@ -13,10 +13,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 += " $(d)-try-build $(IPFS_BIN_$(d)): GOFLAGS += $(cmd/ipfs_flags) diff --git a/config.mk b/config.mk new file mode 100644 index 0000000000000000000000000000000000000000..de8ebfb764ce1a49b419e76fe09d44ae69b71b59 --- /dev/null +++ b/config.mk @@ -0,0 +1,2 @@ +CONFIG_COMMIT := $(shell git rev-parse --short HEAD) +CONFIG_PLUGIN_PATH = ${PLUGIN_PATH} diff --git a/test/sharness/Rules.mk b/test/sharness/Rules.mk index 188cb50cb9b97a5a88e30099d66bd48c6bc939b3..ba69f64332f33e9e3ac0208cfc1385d2e8f3d376 100644 --- a/test/sharness/Rules.mk +++ b/test/sharness/Rules.mk @@ -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/ @@ -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 diff --git a/test/sharness/t0280-plugin-git.sh b/test/sharness/t0280-plugin-git.sh index a93dfdebab3d0e2c79ea26108f91e4b3266f9ec7..f3378b106c40ca03297192b95c0169c5c14e4f42 100755 --- a/test/sharness/t0280-plugin-git.sh +++ b/test/sharness/t0280-plugin-git.sh @@ -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 @@ -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