@cryptotaxi247 / kubo / commits / f63022258

make: rework makefiles for non-recursive make and add sharness coverage

This commit introduces non-recursive Makefile infrastructure that replaces current Makefile infrastructure. It also generally cleanups the Makefiles, separates them into nicer sub-modules and centralizes common operations into single definitions. It allows to depend on any target that is defined in the makefile, this means that for example `gx install` is called once when `make build test_expensive_sharness` is called instead of 4 or 5 times. It also makes the dependencies much cleaner and allows for reuse of modules. For example sharness coverage collection (WIP) uses sharness target with amended PATH, previously it might have been possible but not without wiring in the coverage collection into sharness make runner code. Yes, it is more complex but not much more. There are few rules that have to be followed and few complexities added but IMHO it is worth it. How to NR-make: 1. If make is to generate some file via a target, it MUST be defined in Rules.mk file in the directory of the target. 2. `Rules.mk` file MUST have `include mk/header.mk` statement as the first line and `include mk/footer.mk` statement as the last line (apart from project root `Rules.mk`). 3. It then MUST be included by the closest `Rules.mk` file up the directory tree. 4. Inside a `Rules.mk` special variable accessed as `$(d)` is defined. Its value is current directory, use it so if the `Rules.mk` file is moved in the tree it still works without a problem. Caution: this variable is not available in the recipe part and MUST NOT be used. Use name of the target or prerequisite to extract it if you need it. 5. Make has only one global scope, this means that name conflicts are a thing. Names SHOULD follow `VAR_NAME_$(d)` convention. There are exceptions from this rule in form of well defined global variables. Examples: General lists `TGT_BIN`, `CLEAN`; General targets: `TEST`, `COVERAGE`; General variables: `GOFLAGS`, `DEPS_GO`. 3. Any rules, definitions or variables that fit some family SHOULD be defined in `mk/$family.mk` file and included from project root `Rules.mk` License: MIT Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>

Jakub Sztandera committed Dec 16, 2016 at 19:04 UTC f630222580ffaa9e5c62610773f391a8c6416556
42 files changed +640 -457
Makefile
+6 -191
@@ -1,195 +1,10 @@
1 -# Minimum version numbers for software required to build IPFS
2 -IPFS_MIN_GO_VERSION = 1.7
3 -IPFS_MIN_GX_VERSION = 0.6
4 -IPFS_MIN_GX_GO_VERSION = 1.1
1 +# General tools
2
6 -GOTAGS =
7 -GOTAGS += "" # we have to have always at least one tag, empty tag works well
3 +SHELL=PATH=$(PATH) /bin/sh
4
9 -GOFLAGS =
10 -GOTFLAGS =
5 +PROTOC = protoc --gogo_out=. --proto_path=.:/usr/local/opt/protobuf/include:$(dir $@) $<
6
12 -export IPFS_REUSEPORT=false
13 -export GOFLAGS
14 -export GOTFLAGS
7 +# enable second expansion
8 +.SECONDEXPANSION:
9
16 -GOFLAGS += -tags $(call join-with,$(comma),$(GOTAGS))
17 -
18 -ifeq ($(TEST_NO_FUSE),1)
19 - GOTAGS += nofuse
20 -endif
21 -
22 -ifeq ($(OS),Windows_NT)
23 - GOPATH_DELIMITER = ;
24 -else
25 - GOPATH_DELIMITER = :
26 -endif
27 -
28 -dist_root=/ipfs/QmNZL8wNsvAGdVYr8uGeUE9aGfHjFpHegAWywQFEdSaJbp
29 -gx_bin=bin/gx-v0.9.0
30 -gx-go_bin=bin/gx-go-v1.3.0
31 -
32 -
33 -# util functions
34 -
35 -space =
36 -space +=
37 -comma =,
38 -join-with = $(subst $(space),$1,$(strip $2))
39 -# use things in our bin before any other system binaries
40 -export PATH := bin:$(PATH)
41 -export IPFS_API ?= v04x.ipfs.io
42 -
43 -all: help
44 -
45 -godep:
46 - go get github.com/tools/godep
47 -
48 -go_check:
49 - @bin/check_go_version $(IPFS_MIN_GO_VERSION)
50 -
51 -bin/gx-v%:
52 - @echo "installing gx $(@:bin/gx-%=%)"
53 - @bin/dist_get ${dist_root} gx $@ $(@:bin/gx-%=%)
54 - rm -f bin/gx
55 - ln -s $(@:bin/%=%) bin/gx
56 -
57 -bin/gx-go-v%:
58 - @echo "installing gx-go $(@:bin/gx-go-%=%)"
59 - @bin/dist_get ${dist_root} gx-go $@ $(@:bin/gx-go-%=%)
60 - rm -f bin/gx-go
61 - ln -s $(@:bin/%=%) bin/gx-go
62 -
63 -gx_check: ${gx_bin} ${gx-go_bin}
64 -
65 -path_check:
66 - @bin/check_go_path $(realpath $(shell pwd)) $(realpath $(addsuffix /src/github.com/ipfs/go-ipfs,$(subst $(GOPATH_DELIMITER), ,$(GOPATH))))
67 -
68 -deps: go_check gx_check path_check $(covertools_rule)
69 - ${gx_bin} --verbose install --global
70 -
71 -deps_covertools:
72 - go get -u github.com/wadey/gocovmerge
73 - go get -u golang.org/x/tools/cmd/cover
74 -
75 -# saves/vendors third-party dependencies to Godeps/_workspace
76 -# -r flag rewrites import paths to use the vendored path
77 -# ./... performs operation on all packages in tree
78 -vendor: godep
79 - godep save -r ./...
80 -
81 -nofuse: GOTAGS += nofuse
82 -nofuse: deps
83 - $(MAKE) -C cmd/ipfs install
84 -
85 -install build: deps
86 - $(MAKE) -C cmd/ipfs $@
87 -
88 -clean:
89 - $(MAKE) -C cmd/ipfs clean
90 - $(MAKE) -C test clean
91 -
92 -uninstall:
93 - $(MAKE) -C cmd/ipfs uninstall
94 -
95 -PHONY += all help godep gx_check covertools
96 -PHONY += go_check deps vendor install build nofuse clean uninstall
97 -
98 -##############################################################
99 -# tests targets
100 -
101 -test: test_expensive
102 -
103 -test_short: test_go_fmt build test_go_short test_sharness_short
104 -
105 -test_expensive: test_go_fmt build test_go_expensive test_sharness_expensive windows_build_check
106 -
107 -test_3node:
108 - $(MAKE) -C test/3nodetest
109 -
110 -test_go_fmt:
111 - bin/test-go-fmt
112 -
113 -test_go_short: GOTFLAGS += -test.short
114 -test_go_race: GOTFLAGS += -race
115 -test_go_expensive test_go_short test_go_race:
116 - go test $(GOFLAGS) $(GOTFLAGS) ./...
117 -
118 -coverage: deps_covertools
119 - @echo Running coverage
120 - $(eval PKGS := $(shell go list -f '{{if (len .GoFiles)}}{{.ImportPath}}{{end}}' ./... | grep -v /vendor/ | grep -v /Godeps/))
121 -#$(eval PKGS_DELIM := $(call join-with,$(comma),$(PKGS)))
122 - @go list -f '{{if or (len .TestGoFiles) (len .XTestGoFiles)}}go test $(GOFLAGS) $(GOTFLAGS) -covermode=atomic -coverprofile={{.Name}}_{{len .Imports}}_{{len .Deps}}.coverprofile {{.ImportPath}}{{end}}' $(GOFLAGS) $(PKGS) | xargs -I {} bash -c {} 2>&1 | grep -v 'warning: no packages being tested depend on'
123 - gocovmerge `ls *.coverprofile` > coverage.txt
124 - rm *.coverprofile
125 - bash -c 'bash <(curl -s https://codecov.io/bash)'
126 -
127 -test_sharness_short:
128 - $(MAKE) -j1 -C test/sharness/
129 -
130 -test_sharness_expensive:
131 - TEST_EXPENSIVE=1 $(MAKE) -j1 -C test/sharness/
132 -
133 -test_all_commits:
134 - @echo "testing all commits between origin/master..HEAD"
135 - @echo "WARNING: this will 'git rebase --exec'."
136 - @test/bin/continueyn
137 - GIT_EDITOR=true git rebase -i --exec "$(MAKE) test" origin/master
138 -
139 -test_all_commits_travis:
140 - # these are needed because travis.
141 - # we don't use this yet because it takes way too long.
142 - git config --global user.email "nemo@ipfs.io"
143 - git config --global user.name "IPFS BOT"
144 - git fetch origin master:master
145 - GIT_EDITOR=true git rebase -i --exec "$(MAKE) test" master
146 -
147 -# since we have CI for osx and linux but not windows, this should help
148 -windows_build_check:
149 - GOOS=windows GOARCH=amd64 go build -o .test.ipfs.exe ./cmd/ipfs
150 - rm -f .test.ipfs.exe
151 -
152 -PHONY += test test_short test_expensive
153 -
154 -##############################################################
155 -# A semi-helpful help message
156 -
157 -help:
158 - @echo 'DEPENDENCY TARGETS:'
159 - @echo ''
160 - @echo ' gx_check - Installs or upgrades gx and gx-go'
161 - @echo ' deps - Download dependencies using gx'
162 - @echo ' vendor - Create a Godep workspace of 3rd party dependencies'
163 - @echo ''
164 - @echo 'BUILD TARGETS:'
165 - @echo ''
166 - @echo ' all - print this help message'
167 - @echo ' build - Build binary at ./cmd/ipfs/ipfs'
168 - @echo ' nofuse - Build binary with no fuse support'
169 - @echo ' install - Build binary and install into $$GOPATH/bin'
170 -# @echo ' dist_install - TODO: c.f. ./cmd/ipfs/dist/README.md'
171 - @echo ''
172 - @echo 'CLEANING TARGETS:'
173 - @echo ''
174 - @echo ' clean - Remove binary from build directory'
175 - @echo ' uninstall - Remove binary from $$GOPATH/bin'
176 - @echo ''
177 - @echo 'TESTING TARGETS:'
178 - @echo ''
179 - @echo ' test - Run expensive tests and Window$$ check'
180 - @echo ' test_short - Run short tests and sharness tests'
181 - @echo ' test_expensive - Run a few extras'
182 - @echo ' test_3node'
183 - @echo ' test_go_short'
184 - @echo ' test_go_expensive'
185 - @echo ' test_go_race'
186 - @echo ' test_sharness_short'
187 - @echo ' test_sharness_expensive'
188 - @echo ' test_all_commits'
189 - @echo " test_all_commits_travis - DON'T USE: takes way too long"
190 - @echo ' windows_build_check'
191 - @echo ''
192 -
193 -PHONY += help
194 -
195 -.PHONY: $(PHONY)
10 +include Rules.mk
Rules.mk new
+137
@@ -0,0 +1,137 @@
1 +TGT_BIN :=
2 +CLEAN :=
3 +COVERAGE :=
4 +DISTCLEAN :=
5 +TEST :=
6 +TEST_SHORT :=
7 +
8 +all: help # all has to be first defined target
9 +.PHONY: all
10 +
11 +include mk/util.mk
12 +include mk/golang.mk
13 +include mk/gx.mk
14 +
15 +# -------------------- #
16 +# sub-files #
17 +# -------------------- #
18 +dir := bin
19 +include $(dir)/Rules.mk
20 +
21 +dir := test
22 +include $(dir)/Rules.mk
23 +
24 +dir := cmd/ipfs
25 +include $(dir)/Rules.mk
26 +
27 +# has to be after cmd/ipfs due to PATH
28 +dir := coverage
29 +include $(dir)/Rules.mk
30 +
31 +dir := namesys/pb
32 +include $(dir)/Rules.mk
33 +
34 +dir := unixfs/pb
35 +include $(dir)/Rules.mk
36 +
37 +dir := merkledag/pb
38 +include $(dir)/Rules.mk
39 +
40 +dir := exchange/bitswap/message/pb
41 +include $(dir)/Rules.mk
42 +
43 +dir := diagnostics/pb
44 +include $(dir)/Rules.mk
45 +
46 +dir := pin/internal/pb
47 +include $(dir)/Rules.mk
48 +
49 +# -------------------- #
50 +# universal rules #
51 +# -------------------- #
52 +
53 +%.pb.go: %.proto
54 + $(PROTOC)
55 +
56 +# -------------------- #
57 +# extra properties #
58 +# -------------------- #
59 +
60 +ifeq ($(TEST_NO_FUSE),1)
61 + GOTAGS += nofuse
62 +endif
63 +export IPFS_REUSEPORT=false
64 +
65 +# -------------------- #
66 +# core targets #
67 +# -------------------- #
68 +
69 +
70 +build: $(TGT_BIN)
71 +.PHONY: build
72 +
73 +clean:
74 + rm -f $(CLEAN)
75 +.PHONY: clean
76 +
77 +coverage: $(COVERAGE)
78 +.PHONY: coverage
79 +
80 +distclean: clean
81 + rm -f $(DISTCLEAN)
82 +.PHONY: distclean
83 +
84 +test: $(TEST)
85 +.PHONY: test
86 +
87 +test_short: $(TEST_SHORT)
88 +.PHONY: test_short
89 +
90 +deps: gx-deps
91 +.PHONY: deps
92 +
93 +nofuse: GOTAGS += nofuse
94 +nofuse: build
95 +.PHONY: nofuse
96 +
97 +install: $$(DEPS_GO)
98 + go install $(go-flags-with-tags) ./cmd/ipfs
99 +.PHONY: install
100 +
101 +uninstall:
102 + go clean -i ./cmd/ipfs
103 +.PHONY: uninstall
104 +
105 +help:
106 + @echo 'DEPENDENCY TARGETS:'
107 + @echo ''
108 + @echo ' deps - Download dependencies using bundled gx'
109 + @echo ' test_sharness_deps - Download and build dependencies for sharness'
110 + @echo ''
111 + @echo 'BUILD TARGETS:'
112 + @echo ''
113 + @echo ' all - print this help message'
114 + @echo ' build - Build binary at ./cmd/ipfs/ipfs'
115 + @echo ' nofuse - Build binary with no fuse support'
116 + @echo ' install - Build binary and install into $$GOPATH/bin'
117 +# @echo ' dist_install - TODO: c.f. ./cmd/ipfs/dist/README.md'
118 + @echo ''
119 + @echo 'CLEANING TARGETS:'
120 + @echo ''
121 + @echo ' clean - Remove files generated by build'
122 + @echo ' distclean - Remove files that are no part of a repository'
123 + @echo ' uninstall - Remove binary from $$GOPATH/bin'
124 + @echo ''
125 + @echo 'TESTING TARGETS:'
126 + @echo ''
127 + @echo ' test - Run expensive tests'
128 + @echo ' test_short - Run short tests and short sharness tests'
129 + @echo ' test_go_short'
130 + @echo ' test_go_expensive'
131 + @echo ' test_go_race'
132 + @echo ' test_sharness_short'
133 + @echo ' test_sharness_expensive'
134 + @echo ' test_sharness_race'
135 + @echo ' coverage - Collects coverage info from unit tests and sharness'
136 + @echo
137 +.PHONY: help
bin/Rules.mk new
+26
@@ -0,0 +1,26 @@
1 +include mk/header.mk
2 +
3 +dist_root_$(d)=/ipfs/QmNZL8wNsvAGdVYr8uGeUE9aGfHjFpHegAWywQFEdSaJbp
4 +
5 +$(d)/gx: $(d)/gx-v0.9.0
6 +$(d)/gx-go: $(d)/gx-go-v1.3.0
7 +
8 +TGTS_$(d) := $(d)/gx $(d)/gx-go
9 +DISTCLEAN += $(wildcard $(d)/gx-v*) $(wildcard $(d)/gx-go-v*)
10 +
11 +PATH := $(realpath $(d)):$(PATH)
12 +
13 +$(TGTS_$(d)):
14 + rm -f $@
15 + ln -s $(notdir $^) $@
16 +
17 +bin/gx-v%:
18 + @echo "installing gx $(@:bin/gx-%=%)"
19 + bin/dist_get $(dist_root_bin) gx $@ $(@:bin/gx-%=%)
20 +
21 +bin/gx-go-v%:
22 + @echo "installing gx-go $(@:bin/gx-go-%=%)"
23 + @bin/dist_get $(dist_root_bin) gx-go $@ $(@:bin/gx-go-%=%)
24 +
25 +CLEAN += $(TGTS_$(d))
26 +include mk/footer.mk
bin/gen-make-dep-chain new
+9
@@ -0,0 +1,9 @@
1 +#!/bin/sh
2 +(for p ; do
3 + printf "%s\n" "$p"
4 +done) | tac |
5 +( read -r PREV ;
6 +while read -r CURR ; do
7 + printf '%s: | %s\n' "$PREV" "$CURR"
8 + PREV="$CURR"
9 +done) | tac
circle.yml
+1 -1
@@ -35,6 +35,6 @@ dependencies:
35
36 test:
37 override:
38 - - case $CIRCLE_NODE_INDEX in 0) make coverage ;; 1) make test_sharness_expensive ;; esac:
38 + - case $CIRCLE_NODE_INDEX in 0) make -j 1 coverage/unit_tests.coverprofile && bash <(curl -s https://codecov.io/bash) -cF unittests -X search -f coverage/unit_tests.coverprofile;; 1) make -j 1 coverage/sharness_tests.coverprofile && bash <(curl -s https://codecov.io/bash) -cF sharness -X search -f coverage/sharness_tests.coverprofile;; esac:
39 pwd: "../.go_workspace/src/$IMPORT_PATH"
40 parallel: true
cmd/ipfs/.gitignore
+1
@@ -1,2 +1,3 @@
1 ipfs
2 +ipfs-test-cover
3 ipfs.exe
cmd/ipfs/Makefile deleted
-16
@@ -1,16 +0,0 @@
1 -COMMIT := $(shell git rev-parse --short HEAD)
2 -GOFLAGS += -ldflags="-X "github.com/ipfs/go-ipfs/repo/config".CurrentCommit=$(COMMIT)"
3 -
4 -all: install
5 -
6 -install:
7 - go install $(GOFLAGS)
8 -
9 -build:
10 - go build -i $(GOFLAGS)
11 -
12 -clean:
13 - go clean $(GOFLAGS)
14 -
15 -uninstall:
16 - go clean -i $(GOFLAGS)
cmd/ipfs/Rules.mk new
+29
@@ -0,0 +1,29 @@
1 +include mk/header.mk
2 +IPFS_BIN_$(d) := $(call go-curr-pkg-tgt)
3 +
4 +TGT_BIN += $(IPFS_BIN_$(d))
5 +CLEAN += $(IPFS_BIN_$(d))
6 +
7 +PATH := $(realpath $(d)):$(PATH)
8 +
9 +# disabled for now
10 +# depend on *.pb.go files in the repo as Order Only (as they shouldn't be rebuilt if exist)
11 +# DPES_OO_$(d) := diagnostics/pb/diagnostics.pb.go exchange/bitswap/message/pb/message.pb.go
12 +# DEPS_OO_$(d) += merkledag/pb/merkledag.pb.go namesys/pb/namesys.pb.go
13 +# DEPS_OO_$(d) += pin/internal/pb/header.pb.go unixfs/pb/unixfs.pb.go
14 +
15 +# uses second expansion to collect all $(DEPS_GO)
16 +$(IPFS_BIN_$(d)): $(d) $$(DEPS_GO) ALWAYS #| $(DEPS_OO_$(d))
17 + $(go-build)
18 +
19 +COVER_BIN_$(d) := $(d)/ipfs-test-cover
20 +CLEAN += $(COVER_BIN_$(d))
21 +
22 +$(COVER_BIN_$(d)): GOTAGS += testrunmain
23 +$(COVER_BIN_$(d)): $(d) $$(DEPS_GO) ALWAYS
24 + $(eval TMP_PKGS := $(shell go list -f '{{range .Deps}}{{.}} {{end}}' $(go-flags-with-tags) ./cmd/ipfs | sed 's/ /\n/g' | grep ipfs/go-ipfs))
25 + $(eval TMP_LIST := $(call join-with,$(comma),$(TMP_PKGS)))
26 + @echo go test $@ -c -covermode atomic -coverpkg ... $(go-flags-with-tags) ./$(@D) # for info
27 + @go test -o $@ -c -covermode atomic -coverpkg $(TMP_LIST) $(go-flags-with-tags) ./$(@D) 2>&1 | (grep -v 'warning: no packages being tested' || true)
28 +
29 +include mk/footer.mk
cmd/ipfs/main.go
+13 -9
@@ -64,6 +64,10 @@ type cmdInvocation struct {
64 // - output the response
65 // - if anything fails, print error, maybe with help
66 func main() {
67 + os.Exit(mainRet())
68 +}
69 +
70 +func mainRet() int {
71 rand.Seed(time.Now().UnixNano())
72 ctx := logging.ContextWithLoggable(context.Background(), loggables.Uuid("session"))
73 var err error
@@ -79,7 +83,7 @@ func main() {
83 stopFunc, err := profileIfEnabled()
84 if err != nil {
85 printErr(err)
82 - os.Exit(1)
86 + return 1
87 }
88 defer stopFunc() // to be executed as late as possible
89
@@ -104,7 +108,7 @@ func main() {
108 if len(os.Args) == 2 {
109 if os.Args[1] == "help" {
110 printHelp(false, os.Stdout)
107 - os.Exit(0)
111 + return 0
112 } else if os.Args[1] == "--version" {
113 os.Args[1] = "version"
114 }
@@ -119,11 +123,11 @@ func main() {
123 longH, shortH, err := invoc.requestedHelp()
124 if err != nil {
125 printErr(err)
122 - os.Exit(1)
126 + return 1
127 }
128 if longH || shortH {
129 printHelp(longH, os.Stdout)
126 - os.Exit(0)
130 + return 0
131 }
132 }
133
@@ -138,7 +142,7 @@ func main() {
142 fmt.Fprintf(os.Stderr, "\n")
143 printHelp(false, os.Stderr)
144 }
141 - os.Exit(1)
145 + return 1
146 }
147
148 // here we handle the cases where
@@ -146,7 +150,7 @@ func main() {
150 // - the main command is invoked.
151 if invoc.cmd == nil || invoc.cmd.Run == nil {
152 printHelp(false, os.Stdout)
149 - os.Exit(0)
153 + return 0
154 }
155
156 // ok, finally, run the command invocation.
@@ -161,16 +165,16 @@ func main() {
165 if isClientError(err) {
166 printMetaHelp(os.Stderr)
167 }
164 - os.Exit(1)
168 + return 1
169 }
170
171 // everything went better than expected :)
172 _, err = io.Copy(os.Stdout, output)
173 if err != nil {
174 printErr(err)
171 -
172 - os.Exit(1)
175 + return 1
176 }
177 + return 0
178 }
179
180 func (i *cmdInvocation) Run(ctx context.Context) (output io.Reader, err error) {
cmd/ipfs/runmain_test.go new
+30
@@ -0,0 +1,30 @@
1 +// +build testrunmain
2 +
3 +package main
4 +
5 +import (
6 + "flag"
7 + "fmt"
8 + "io/ioutil"
9 + "os"
10 + "testing"
11 +)
12 +
13 +// this abuses go so much that I felt dirty writing this code
14 +// but it is the only way to do it without writing custom compiler that would
15 +// be a clone of go-build with go-test
16 +func TestRunMain(t *testing.T) {
17 + args := flag.Args()
18 + os.Args = append([]string{os.Args[0]}, args...)
19 + ret := mainRet()
20 +
21 + p := os.Getenv("IPFS_COVER_RET_FILE")
22 + if len(p) != 0 {
23 + ioutil.WriteFile(p, []byte(fmt.Sprintf("%d\n", ret)), 0777)
24 + }
25 +
26 + // close outputs so go testing doesn't print anything
27 + null, _ := os.Open(os.DevNull)
28 + os.Stderr = null
29 + os.Stdout = null
30 +}
core/commands/config.go
+1 -1
@@ -311,7 +311,7 @@ func editConfig(filename string) error {
311 func replaceConfig(r repo.Repo, file io.Reader) error {
312 var cfg config.Config
313 if err := json.NewDecoder(file).Decode(&cfg); err != nil {
314 - return errors.New("failed to decode file as config")
314 + return errors.New("failed to decode file as config: " + err.Error())
315 }
316 if len(cfg.Identity.PrivKey) != 0 {
317 return errors.New("setting private key with API is not supported")
coverage/.gitignore new
+4
@@ -0,0 +1,4 @@
1 +unitcover
2 +sharnesscover
3 +ipfs
4 +
coverage/Rules.mk new
+51
@@ -0,0 +1,51 @@
1 +include mk/header.mk
2 +
3 +$(d)/coverage_deps:
4 + rm -rf $(@D)/unitcover && mkdir $(@D)/unitcover
5 + rm -rf $(@D)/sharnesscover && mkdir $(@D)/sharnesscover
6 + go get -u github.com/Kubuxu/gocovmerge
7 + go get -u golang.org/x/tools/cmd/cover
8 +.PHONY: $(d)/coverage_deps
9 +
10 +# unit tests coverage
11 +UTESTS_$(d) := $(shell go list -f '{{if (len .TestGoFiles)}}{{.ImportPath}}{{end}}' $(go-flags-with-tags) ./... | grep -v go-ipfs/vendor | grep -v go-ipfs/Godeps)
12 +
13 +UCOVER_$(d) := $(addsuffix .coverprofile,$(addprefix $(d)/unitcover/, $(subst /,_,$(UTESTS_$(d)))))
14 +
15 +$(UCOVER_$(d)): $(d)/coverage_deps ALWAYS
16 + $(eval TMP_PKG := $(subst _,/,$(basename $(@F))))
17 + @go test $(go-flags-with-tags) $(GOTFLAGS) -covermode=atomic -coverprofile=$@ $(TMP_PKG)
18 +
19 +
20 +$(d)/unit_tests.coverprofile: $(UCOVER_$(d))
21 + gocovmerge $^ > $@
22 +
23 +TGTS_$(d) := $(d)/unit_tests.coverprofile
24 +
25 +
26 +# sharness tests coverage
27 +$(d)/ipfs: GOTAGS += testrunmain
28 +$(d)/ipfs: $(d)/main
29 + $(go-build)
30 +
31 +CLEAN += $(d)/ipfs
32 +
33 +ifneq ($(filter coverage,$(MAKECMDGOALS)),)
34 + # this is quite hacky but it is best way I could fiture out
35 + DEPS_test/sharness += cmd/ipfs/ipfs-test-cover $(d)/coverage_deps $(d)/ipfs
36 +endif
37 +
38 +export IPFS_COVER_DIR:= $(realpath $(d))/sharnesscover/
39 +
40 +$(d)/sharness_tests.coverprofile: $(d)/ipfs cmd/ipfs/ipfs-test-cover $(d)/coverage_deps test_sharness_short
41 + (cd $(@D)/sharnesscover && find . -type f | gocovmerge -list -) > $@
42 +
43 +
44 +PATH := $(realpath $(d)):$(PATH)
45 +
46 +TGTS_$(d) += $(d)/sharness_tests.coverprofile
47 +
48 +CLEAN += $(TGTS_$(d))
49 +COVERAGE += $(TGTS_$(d))
50 +
51 +include mk/footer.mk
coverage/main/main.go new
+72
@@ -0,0 +1,72 @@
1 +// +build testrunmain
2 +
3 +package main
4 +
5 +import (
6 + "fmt"
7 + "io/ioutil"
8 + "os"
9 + "os/exec"
10 + "os/signal"
11 + "strconv"
12 + "syscall"
13 +)
14 +
15 +func main() {
16 + coverDir := os.Getenv("IPFS_COVER_DIR")
17 + if len(coverDir) == 0 {
18 + fmt.Println("IPFS_COVER_DIR not defined")
19 + os.Exit(1)
20 + }
21 + coverFile, err := ioutil.TempFile(coverDir, "coverage-")
22 + if err != nil {
23 + fmt.Println(err.Error())
24 + os.Exit(1)
25 + }
26 +
27 + retFile, err := ioutil.TempFile("", "cover-ret-file")
28 + if err != nil {
29 + fmt.Println(err.Error())
30 + os.Exit(1)
31 + }
32 +
33 + args := []string{"-test.run", "^TestRunMain$", "-test.coverprofile=" + coverFile.Name(), "--"}
34 + args = append(args, os.Args[1:]...)
35 +
36 + p := exec.Command("ipfs-test-cover", args...)
37 + p.Stdin = os.Stdin
38 + p.Stdout = os.Stdout
39 + p.Stderr = os.Stderr
40 + p.Env = append(os.Environ(), "IPFS_COVER_RET_FILE="+retFile.Name())
41 +
42 + p.SysProcAttr = &syscall.SysProcAttr{
43 + Pdeathsig: syscall.SIGTERM,
44 + }
45 +
46 + sig := make(chan os.Signal, 1)
47 + go func() {
48 + for {
49 + p.Process.Signal(<-sig)
50 + }
51 + }()
52 + signal.Notify(sig, syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM)
53 +
54 + err = p.Run()
55 + if err != nil {
56 + fmt.Println(err.Error())
57 + os.Exit(1)
58 + }
59 +
60 + b, err := ioutil.ReadAll(retFile)
61 + if err != nil {
62 + fmt.Println(err.Error())
63 + os.Exit(1)
64 + }
65 + b = b[:len(b)-1]
66 + d, err := strconv.Atoi(string(b))
67 + if err != nil {
68 + fmt.Println(err.Error())
69 + os.Exit(1)
70 + }
71 + os.Exit(d)
72 +}
diagnostics/pb/Makefile deleted
-10
@@ -1,10 +0,0 @@
1 -PB = $(wildcard *.proto)
2 -GO = $(PB:.proto=.pb.go)
3 -
4 -all: $(GO)
5 -
6 -%.pb.go: %.proto
7 - protoc --gogo_out=. --proto_path=../../../../../../:/usr/local/opt/protobuf/include:. $<
8 -
9 -clean:
10 - rm *.pb.go
diagnostics/pb/Rules.mk new
+8
@@ -0,0 +1,8 @@
1 +include mk/header.mk
2 +
3 +PB_$(d) = $(wildcard $(d)/*.proto)
4 +TGTS_$(d) = $(PB_$(d):.proto=.pb.go)
5 +
6 +#DEPS_GO += $(TGTS_$(d))
7 +
8 +include mk/footer.mk
exchange/bitswap/message/pb/Makefile deleted
-8
@@ -1,8 +0,0 @@
1 -# TODO(brian): add proto tasks
2 -all: message.pb.go
3 -
4 -message.pb.go: message.proto
5 - protoc --gogo_out=. --proto_path=../../../../../:/usr/local/opt/protobuf/include:. $<
6 -
7 -clean:
8 - rm message.pb.go
exchange/bitswap/message/pb/Rules.mk new
+8
@@ -0,0 +1,8 @@
1 +include mk/header.mk
2 +
3 +PB_$(d) = $(wildcard $(d)/*.proto)
4 +TGTS_$(d) = $(PB_$(d):.proto=.pb.go)
5 +
6 +#DEPS_GO += $(TGTS_$(d))
7 +
8 +include mk/footer.mk
merkledag/pb/Makefile deleted
-11
@@ -1,11 +0,0 @@
1 -PB = $(wildcard *.proto)
2 -GO = $(PB:.proto=.pb.go)
3 -
4 -all: $(GO)
5 -
6 -%.pb.go: %.proto
7 - protoc --gogo_out=. --proto_path=../../../../../../:/usr/local/opt/protobuf/include:. $<
8 -
9 -clean:
10 - rm -f *.pb.go
11 - rm -f *.go
merkledag/pb/Rules.mk new
+8
@@ -0,0 +1,8 @@
1 +include mk/header.mk
2 +
3 +PB_$(d) = $(wildcard $(d)/*.proto)
4 +TGTS_$(d) = $(PB_$(d):.proto=.pb.go)
5 +
6 +#DEPS_GO += $(TGTS_$(d))
7 +
8 +include mk/footer.mk
mk/footer.mk new
+2
@@ -0,0 +1,2 @@
1 +d := $(dirstack_$(sp))
2 +sp := $(basename $(sp))
mk/golang.mk new
+50
@@ -0,0 +1,50 @@
1 +# golang utilities
2 +GO_MIN_VERSION = 1.7
3 +
4 +# pre-definitions
5 +GOTAGS ?=
6 +GOFLAGS ?=
7 +GOTFLAGS ?=
8 +
9 +DEPS_GO :=
10 +TEST_GO :=
11 +CHECK_GO :=
12 +
13 +go-pkg-name=$(shell go list $(go-tags) ./$(1))
14 +go-main-name=$(notdir $(call go-pkg-name,$(1)))$(?exe)
15 +go-curr-pkg-tgt=$(d)/$(call go-main-name,$(d))
16 +
17 +go-tags=$(if $(GOTAGS), -tags $(call join-with,$(comma),$(GOTAGS)))
18 +go-flags-with-tags=$(GOFLAGS)$(go-tags)
19 +
20 +define go-build
21 +go build -i $(go-flags-with-tags) -o "$@" "$(call go-pkg-name,$<)"
22 +endef
23 +
24 +test_go_short: GOTFLAGS += -test.short
25 +test_go_short: test_go_expensive
26 +.PHONY: test_go_short
27 +
28 +test_go_race: GOTFLAGS += -race
29 +test_go_race: test_go_expensive
30 +.PHONY: test_go_race
31 +
32 +test_go_expensive: $$(DEPS_GO)
33 + go test $(go-flags-with-tags) $(GOTFLAGS) ./...
34 +.PHONY: test_go_expensive
35 +TEST_GO += test_go_expensive
36 +
37 +test_go_fmt:
38 + bin/test-go-fmt
39 +.PHONY: test_go_fmt
40 +TEST_GO += test_go_fmt
41 +
42 +test_go: $(TEST_GO)
43 +
44 +check_go_version:
45 + bin/check_go_version $(GO_MIN_VERSION)
46 +.PHONY: check_go_version
47 +CHECK_GO += check_go_version
48 +
49 +TEST += $(TEST_GO)
50 +TEST_SHORT += test_go_fmt test_go_short
mk/gx.mk new
+6
@@ -0,0 +1,6 @@
1 +gx-path = gx/ipfs/$(shell gx deps find $(1))/$(1)
2 +
3 +gx-deps: bin/gx bin/gx-go $(CHECK_GO)
4 + gx install --global >/dev/null 2>&1
5 +
6 +DEPS_GO += gx-deps
mk/header.mk new
+4
@@ -0,0 +1,4 @@
1 +# keep track of dirs
2 +p := $(sp).x
3 +dirstack_$(sp) := $(d)
4 +d := $(dir)
mk/util.mk new
+20
@@ -0,0 +1,20 @@
1 +# util functions
2 +ifeq ($(OS),Windows_NT)
3 + WINDOWS :=1
4 + ?exe :=.exe # windows compat
5 +else
6 + ?exe :=
7 +endif
8 +
9 +space:=
10 +space+=
11 +comma:=,
12 +join-with=$(subst $(space),$1,$(strip $2))
13 +
14 +# debug target, prints varaible. Example: `make print-GOFLAGS`
15 +print-%:
16 + @echo $*=$($*)
17 +
18 +# phony target that will mean that recipe is always exectued
19 +ALWAYS:
20 +.PHONY: ALWAYS
namesys/pb/Makefile deleted
-10
@@ -1,10 +0,0 @@
1 -PB = $(wildcard *.proto)
2 -GO = $(PB:.proto=.pb.go)
3 -
4 -all: $(GO)
5 -
6 -%.pb.go: %.proto
7 - protoc --gogo_out=. --proto_path=../../../../../../:/usr/local/opt/protobuf/include:. $<
8 -
9 -clean:
10 - rm *.pb.go
namesys/pb/Rules.mk new
+8
@@ -0,0 +1,8 @@
1 +include mk/header.mk
2 +
3 +PB_$(d) = $(wildcard $(d)/*.proto)
4 +TGTS_$(d) = $(PB_$(d):.proto=.pb.go)
5 +
6 +#DEPS_GO += $(TGTS_$(d))
7 +
8 +include mk/footer.mk
pin/internal/pb/Rules.mk new
+8
@@ -0,0 +1,8 @@
1 +include mk/header.mk
2 +
3 +PB_$(d) = $(wildcard $(d)/*.proto)
4 +TGTS_$(d) = $(PB_$(d):.proto=.pb.go)
5 +
6 +#DEPS_GO += $(TGTS_$(d))
7 +
8 +include mk/footer.mk
pin/pin.go
+3 -3
@@ -5,7 +5,6 @@ package pin
5 import (
6 "context"
7 "fmt"
8 - "os"
8 "sync"
9 "time"
10
@@ -26,8 +25,9 @@ var emptyKey *cid.Cid
25 func init() {
26 e, err := cid.Decode("QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n")
27 if err != nil {
29 - log.Error("failed to decode empty key constant")
30 - os.Exit(1)
28 + msg := "failed to decode empty key constant"
29 + log.Error(msg)
30 + panic(msg)
31 }
32 emptyKey = e
33 }
test/Makefile deleted
-115
@@ -1,115 +0,0 @@
1 -
2 -BINS = bin/random bin/multihash bin/ipfs bin/pollEndpoint bin/iptb bin/go-sleep
3 -BINS += bin/go-timeout
4 -IPFS_ROOT = ../
5 -IPFS_CMD = ../cmd/ipfs
6 -RANDOM_SRC = ../Godeps/_workspace/src/github.com/jbenet/go-random
7 -RANDOM_FILES_SRC = ../Godeps/_workspace/src/github.com/jbenet/go-random-files
8 -POLLENDPOINT_SRC= ../thirdparty/pollEndpoint
9 -GOSLEEP_SRC = ./dependencies/go-sleep
10 -GOTIMEOUT_SRC = ./dependencies/go-timeout
11 -
12 -export PATH := ../bin:${PATH}
13 -
14 -# User might want to override those on the command line
15 -GOFLAGS =
16 -
17 -all: deps
18 -
19 -global-deps:
20 - $(MAKE) -C .. deps
21 -
22 -deps: global-deps bins
23 -
24 -clean:
25 - $(MAKE) -C sharness clean
26 - rm -rf $(BINS)
27 -
28 -bins: $(BINS)
29 -
30 -find_go_files = $(shell find $(1) -name "*.go")
31 -
32 -# Non gx dependencies
33 -
34 -bin/random: $(call find_go_files, $(RANDOM_SRC)) IPFS-BUILD-OPTIONS
35 - @echo "*** installing $@ ***"
36 - go build $(GOFLAGS) -o bin/random $(RANDOM_SRC)/random
37 -
38 -bin/random-files:
39 - @echo "*** installing $@ ***"
40 - go build $(GOFLAGS) -o bin/random-files $(RANDOM_FILES_SRC)/random-files
41 -
42 -bin/ipfs: $(call find_go_files, $(IPFS_ROOT)) IPFS-BUILD-OPTIONS
43 - @echo "*** installing $@ ***"
44 - go build $(GOFLAGS) -o bin/ipfs $(IPFS_CMD)
45 -
46 -bin/pollEndpoint: $(call find_go_files, $(POLLENDPOINT_SRC)) IPFS-BUILD-OPTIONS
47 - @echo "*** installing $@ ***"
48 - go build $(GOFLAGS) -o bin/pollEndpoint $(POLLENDPOINT_SRC)
49 -
50 -bin/go-sleep: $(call find_go_files, $(GOSLEEP_SRC)) IPFS-BUILD-OPTIONS
51 - @echo "*** installing $@ ***"
52 - go build $(GOFLAGS) -o bin/go-sleep $(GOSLEEP_SRC)
53 -
54 -bin/go-timeout: $(call find_go_files, $(GOTIMEOUT_SRC)) IPFS-BUILD-OPTIONS
55 - @echo "*** installing $@ ***"
56 - go build $(GOFLAGS) -o bin/go-timeout $(GOTIMEOUT_SRC)
57 -
58 -# gx dependencies
59 -
60 -multihash_src:
61 - $(eval MULTIHASH_HASH := $(shell cd .. && bin/gx deps find go-multihash))
62 - $(eval MULTIHASH_SRC := gx/ipfs/$(MULTIHASH_HASH)/go-multihash)
63 -
64 -hang-fds_src:
65 - $(eval HANG_FDS_HASH := $(shell cd .. && bin/gx deps find hang-fds))
66 - $(eval HANG_FDS_SRC := gx/ipfs/$(HANG_FDS_HASH)/hang-fds)
67 -
68 -bin/multihash: multihash_src $(call find_go_files, $(MULTIHASH_SRC)) IPFS-BUILD-OPTIONS
69 - @echo "*** installing $@ ***"
70 - go build $(GOFLAGS) -o bin/multihash $(MULTIHASH_SRC)/multihash
71 -
72 -bin/hang-fds: hang-fds_src $(call find_go_files, $(HANG_FDS_SRC)) IPFS-BUILD-OPTIONS
73 - @echo "*** installing $@ ***"
74 - go build $(GOFLAGS) -o bin/hang-fds $(HANG_FDS_SRC)
75 -
76 -iptb_src:
77 - $(eval IPTB_HASH := $(shell cd .. && bin/gx deps find iptb))
78 - $(eval IPTB_SRC := gx/ipfs/$(IPTB_HASH)/iptb)
79 -
80 -bin/iptb: iptb_src $(call find_go_files, $(IPTB_SRC)) IPFS-BUILD-OPTIONS
81 - @echo "*** installing $@ ***"
82 - go build $(GOFLAGS) -o bin/iptb $(IPTB_SRC)
83 -
84 -# Tests
85 -
86 -test: test_expensive
87 -
88 -test_expensive: verify_gofmt
89 - $(MAKE) -C sharness TEST_EXPENSIVE=1
90 - $(MAKE) -C 3nodetest
91 - $(MAKE) -C dependencies
92 -
93 -test_cheap: verify_gofmt
94 - $(MAKE) -C sharness
95 - $(MAKE) -C 3nodetest
96 -
97 -test_race: verify_gofmt
98 - $(MAKE) -C sharness GOFLAGS=-race TEST_EXPENSIVE=1
99 - $(MAKE) -C 3nodetest GOFLAGS=-race
100 - $(MAKE) -C dependencies GOFLAGS=-race
101 -
102 -# Misc
103 -
104 -coverage: coverage_sharness
105 -
106 -coverage_sharness:
107 - ./sharness_test_coverage_helper.sh
108 -
109 -IPFS-BUILD-OPTIONS: FORCE
110 - @bin/checkflags '$@' '$(GOFLAGS)' '*** new Go flags ***'
111 -
112 -verify_gofmt:
113 - bin/verify-go-fmt.sh
114 -
115 -.PHONY: all clean FORCE
test/Rules.mk new
+9
@@ -0,0 +1,9 @@
1 +include mk/header.mk
2 +
3 +dir := $(d)/bin
4 +include $(dir)/Rules.mk
5 +
6 +dir := $(d)/sharness
7 +include $(dir)/Rules.mk
8 +
9 +include mk/footer.mk
test/bin/.gitignore
+1
@@ -8,3 +8,4 @@
8 !checkflags
9 !continueyn
10 !verify-go-fmt.sh
11 +!Rules.mk
test/bin/Rules.mk new
+44
@@ -0,0 +1,44 @@
1 +include mk/header.mk
2 +
3 +TGTS_$(d) :=
4 +
5 +$(d)/random: Godeps/_workspace/src/github.com/jbenet/go-random/random
6 + $(go-build)
7 +TGTS_$(d) += $(d)/random
8 +
9 +$(d)/random-files: Godeps/_workspace/src/github.com/jbenet/go-random-files/random-files
10 + $(go-build)
11 +TGTS_$(d) += $(d)/random-files
12 +
13 +$(d)/pollEndpoint: thirdparty/pollEndpoint
14 + $(go-build)
15 +TGTS_$(d) += $(d)/pollEndpoint
16 +
17 +$(d)/go-sleep: test/dependencies/go-sleep
18 + $(go-build)
19 +TGTS_$(d) += $(d)/go-sleep
20 +
21 +$(d)/go-timeout: test/dependencies/go-timeout
22 + $(go-build)
23 +TGTS_$(d) += $(d)/go-timeout
24 +
25 +TGTS_GX_$(d) := hang-fds iptb
26 +TGTS_GX_$(d) := $(addprefix $(d)/,$(TGTS_GX_$(d)))
27 +
28 +$(TGTS_GX_$(d)):
29 + go build -i $(go-flags-with-tags) -o "$@" "$(call gx-path,$(notdir $@))"
30 +
31 +TGTS_$(d) += $(TGTS_GX_$(d))
32 +
33 +# multihash is special
34 +$(d)/multihash:
35 + go build -i $(go-flags-with-tags) -o "$@" "gx/ipfs/$(shell gx deps find go-multihash)/go-multihash/multihash"
36 +TGTS_$(d) += $(d)/multihash
37 +
38 +$(TGTS_$(d)): $$(DEPS_GO)
39 +
40 +CLEAN += $(TGTS_$(d))
41 +
42 +PATH := $(realpath $(d)):$(PATH)
43 +
44 +include mk/footer.mk
test/sharness/Makefile deleted
-57
@@ -1,57 +0,0 @@
1 -# Run tests
2 -#
3 -# Copyright (c) 2014 Christian Couder
4 -# MIT Licensed; see the LICENSE file in this repository.
5 -#
6 -
7 -# NOTE: Run with TEST_VERBOSE=1 for verbose sharness tests.
8 -
9 -T = $(sort $(wildcard t[0-9][0-9][0-9][0-9]-*.sh))
10 -BINS = bin/random bin/multihash bin/ipfs bin/pollEndpoint \
11 - bin/iptb bin/go-sleep bin/random-files bin/go-timeout bin/hang-fds
12 -SHARNESS = lib/sharness/sharness.sh
13 -IPFS_ROOT = ../..
14 -
15 -# User might want to override those on the command line
16 -GOFLAGS =
17 -
18 -all: aggregate
19 -
20 -clean: clean-test-results
21 - @echo "*** $@ ***"
22 - rm -rf $(BINS)
23 -
24 -clean-test-results:
25 - @echo "*** $@ ***"
26 - rm -rf test-results
27 -
28 -$(T): clean-test-results deps
29 - @echo "*** $@ ***"
30 - ./$@
31 -
32 -aggregate: clean-test-results $(T)
33 - @echo "*** $@ ***"
34 - lib/test-aggregate-results.sh
35 -
36 -global-deps:
37 - $(MAKE) -C ../.. deps
38 -
39 -deps: global-deps $(SHARNESS) $(BINS) curl
40 -
41 -$(SHARNESS): FORCE
42 - @echo "*** checking $@ ***"
43 - lib/install-sharness.sh
44 -
45 -bin/%: FORCE
46 - $(MAKE) -C .. GOFLAGS=$(GOFLAGS) $@
47 -
48 -race:
49 - $(MAKE) GOFLAGS=-race all
50 -
51 -.PHONY: all clean $(T) aggregate FORCE
52 -
53 -# will fail if curl is not installed.
54 -# TODO: get rid of this and install curl with git or ipfs.
55 -install_curl_pls = "curl is required to run tests. please install it"
56 -curl:
57 - @which curl >/dev/null || (echo "$(install_curl_pls)" && false)
test/sharness/README.md
+2 -1
@@ -37,7 +37,8 @@ $ ./t0010-basic-commands.sh -v -i
37
38 ## Sharness
39
40 -When running "make" in this directory for the first time, sharness
40 +When running sharness tests from main Makefile or when `test_sharness_deps`
41 +target is run dependencies for sharness
42 will be downloaded from its github repo and installed in a "lib/sharness"
43 directory.
44
test/sharness/Rules.mk new
+54
@@ -0,0 +1,54 @@
1 +include mk/header.mk
2 +
3 +
4 +SHARNESS_$(d) = $(d)/lib/sharness/sharness.sh
5 +
6 +T_$(d) = $(sort $(wildcard $(d)/t[0-9][0-9][0-9][0-9]-*.sh))
7 +
8 +DEPS_$(d) := test/bin/random test/bin/multihash test/bin/pollEndpoint \
9 + test/bin/iptb test/bin/go-sleep test/bin/random-files \
10 + test/bin/go-timeout test/bin/hang-fds
11 +DEPS_$(d) += cmd/ipfs/ipfs
12 +DEPS_$(d) += $(d)/clean-test-results
13 +DEPS_$(d) += $(SHARNESS_$(d))
14 +
15 +export MAKE_SKIP_PATH=1
16 +
17 +$(T_$(d)): $$(DEPS_$(d)) # use second expansion so coverage can inject dependency
18 + @echo "*** $@ ***"
19 + @(cd $(@D) && ./$(@F)) 2>&1
20 +.PHONY: $(T_$(d))
21 +
22 +$(d)/aggregate: $(T_$(d))
23 + @echo "*** $@ ***"
24 + @(cd $(@D) && ./lib/test-aggregate-results.sh)
25 +.PHONY: $(d)/aggregate
26 +
27 +$(d)/clean-test-results:
28 + rm -rf $(@D)/test-results
29 +.PHONY: $(d)/clean-test-results
30 +
31 +CLEAN += $(wildcard $(d)/test-results/*)
32 +
33 +$(SHARNESS_$(d)): $(d) ALWAYS
34 + @clonedir=$(dir $(@D)) $</lib/install-sharness.sh
35 +
36 +test_sharness_deps: $(SHARNESS_$(d)) $$(DEPS_$(d)) # use second expansion so coverage can inject dependency
37 +.PHONY: test_sharness_deps
38 +
39 +test_sharness_short: $(d)/aggregate
40 +.PHONY: test_sharness_short
41 +
42 +
43 +test_sharness_expensive: export TEST_EXPENSIVE=1
44 +test_sharness_expensive: test_sharness_short
45 +.PHONY: test_sharness_expensive
46 +
47 +test_sharness_race: GOFLAGS += -race
48 +.PHONY: test_sharness_race
49 +
50 +TEST += test_sharness_expensive
51 +TEST_SHORT += test_sharness_short
52 +
53 +
54 +include mk/footer.mk
test/sharness/bin deleted
-1
@@ -1 +0,0 @@
1 -../bin
\ No newline at end of file
test/sharness/lib/install-sharness.sh
+3 -1
@@ -8,7 +8,9 @@
8 # settings
9 version=5eee9b51b5621cec95a64018f0cc779963b230d2
10 urlprefix=https://github.com/mlafeldt/sharness.git
11 -clonedir=lib
11 +if test ! -n "$clonedir" ; then
12 + clonedir=lib
13 +fi
14 sharnessdir=sharness
15
16 if test -f "$clonedir/$sharnessdir/SHARNESS_VERSION_$version"
test/sharness/lib/test-lib.sh
+12 -11
@@ -9,22 +9,23 @@
9 # use the ipfs tool to test against
10
11 # add current directory to path, for ipfs tool.
12 -BIN=$(cd .. && echo `pwd`/bin)
13 -PATH=${BIN}:${PATH}
12 +if test "$MAKE_SKIP_PATH" -ne "1"; then
13 + BIN=$(cd .. && echo `pwd`/bin)
14 + BIN2=$(cd ../.. && echo `pwd`/cmd/ipfs)
15 + PATH=${BIN2}:${BIN}:${PATH}
16 +
17 + # assert the `ipfs` we're using is the right one.
18 + if test `which ipfs` != ${BIN2}/ipfs; then
19 + echo >&2 "Cannot find the tests' local ipfs tool."
20 + echo >&2 "Please check test and ipfs tool installation."
21 + exit 1
22 + fi
23 +fi
24
25 # set sharness verbosity. we set the env var directly as
26 # it's too late to pass in --verbose, and --verbose is harder
27 # to pass through in some cases.
28 test "$TEST_VERBOSE" = 1 && verbose=t
19 -
20 -# assert the `ipfs` we're using is the right one.
21 -if test `which ipfs` != ${BIN}/ipfs; then
22 - echo >&2 "Cannot find the tests' local ipfs tool."
23 - echo >&2 "Please check test and ipfs tool installation."
24 - exit 1
25 -fi
26 -
27 -
29 # source the common hashes first.
30 . lib/test-lib-hashes.sh
31
test/sharness/t0600-issues-and-regressions-online.sh
+2 -1
@@ -37,7 +37,8 @@ test_kill_ipfs_daemon
37
38 test_expect_success "ipfs daemon --offline --mount fails - #2995" '
39 test_expect_code 1 ipfs daemon --offline --mount 2>daemon_err &&
40 - grep "mount is not currently supported in offline mode" daemon_err
40 + grep "mount is not currently supported in offline mode" daemon_err ||
41 + test_fsh cat daemon_err
42 '
43
44 test_done
unixfs/pb/Makefile deleted
-10
@@ -1,10 +0,0 @@
1 -PB = $(wildcard *.proto)
2 -GO = $(PB:.proto=.pb.go)
3 -
4 -all: $(GO)
5 -
6 -%.pb.go: %.proto
7 - protoc --gogo_out=. --proto_path=../../../../../../:/usr/local/opt/protobuf/include:. $<
8 -
9 -clean:
10 - rm *.pb.go
unixfs/pb/Rules.mk new
+8
@@ -0,0 +1,8 @@
1 +include mk/header.mk
2 +
3 +PB_$(d) = $(wildcard $(d)/*.proto)
4 +TGTS_$(d) = $(PB_$(d):.proto=.pb.go)
5 +
6 +#DEPS_GO += $(TGTS_$(d))
7 +
8 +include mk/footer.mk