]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/blob - Makefile
Update coverage-related targets in Makefile. refs #1698
[tahoe-lafs/tahoe-lafs.git] / Makefile
1
2 # NOTE: this Makefile requires GNU make
3
4 default: build
5
6 PYTHON=python
7 export PYTHON
8
9 # setup.py will extend sys.path to include our support/lib/... directory
10 # itself. It will also create it in the beginning of the 'develop' command.
11
12 TAHOE=$(PYTHON) bin/tahoe
13 SOURCES=src/allmydata src/buildtest static misc bin/tahoe-script.template twisted setup.py
14
15 .PHONY: make-version build
16
17 # This is necessary only if you want to automatically produce a new
18 # _version.py file from the current git/darcs history (without doing a build).
19 make-version:
20         $(PYTHON) ./setup.py update_version
21
22 .built:
23         $(MAKE) build
24
25 src/allmydata/_version.py:
26         $(MAKE) make-version
27
28 # It is unnecessary to have this depend on build or src/allmydata/_version.py,
29 # since 'setup.py build' always updates the version.
30 build:
31         $(PYTHON) setup.py build
32         touch .built
33
34
35 # TESTING
36
37 .PHONY: signal-error-deps test check test-coverage quicktest quicktest-coverage
38 .PHONY: coverage-output get-old-coverage-coverage coverage-delta-output
39
40
41 # you can use 'make test TEST=allmydata.test.test_introducer' to run just
42 # test_introducer. TEST=allmydata.test.test_client.Basic.test_permute works
43 # too.
44 TEST=allmydata
45
46 # It is unnecessary to have this depend on build or src/allmydata/_version.py,
47 # since 'setup.py test' always updates the version and builds before testing.
48 test:
49         $(PYTHON) setup.py test $(TRIALARGS) -s $(TEST)
50         touch .built
51
52 check: test
53
54 quicktest: make-version
55         $(TAHOE) debug trial $(TRIALARGS) $(TEST)
56
57 # "make tmpfstest" may be a faster way of running tests on Linux. It works best when you have
58 # at least 330 MiB of free physical memory (to run the whole test suite). Since it uses sudo
59 # to mount/unmount the tmpfs filesystem, it might prompt for your password.
60 tmpfstest:
61         time make _tmpfstest 'TMPDIR=$(shell mktemp -d --tmpdir=.)'
62
63 _tmpfstest: make-version
64         sudo mount -t tmpfs -o size=400m tmpfs '$(TMPDIR)'
65         -$(TAHOE) debug trial --rterrors '--temp-directory=$(TMPDIR)/_trial_temp' $(TRIALARGS) $(TEST)
66         sudo umount '$(TMPDIR)'
67         rmdir '$(TMPDIR)'
68
69
70 # code coverage: install the "coverage" package from PyPI, do "make test-coverage" to
71 # do a unit test run with coverage-gathering enabled, then use "make coverage-output" to
72 # generate an HTML report. Also see "make .coverage.el" and misc/coding_tools/coverage.el
73 # for Emacs integration.
74
75 # This might need to be python-coverage on Debian-based distros.
76 COVERAGE=coverage
77
78 COVERAGEARGS=--branch --source=src/allmydata
79
80 # --include appeared in coverage-3.4
81 COVERAGE_OMIT=--include '$(CURDIR)/src/allmydata/*' --omit '$(CURDIR)/src/allmydata/test/*'
82
83 test-coverage: build
84         rm -f .coverage
85         $(TAHOE) '@$(COVERAGE)' run $(COVERAGEARGS) @tahoe debug trial $(TRIALARGS) $(TEST)
86
87 coverage-output:
88         rm -rf coverage-html
89         coverage html -i -d coverage-html $(COVERAGE_OMIT)
90         cp .coverage coverage-html/coverage.data
91         @echo "now point your browser at coverage-html/index.html"
92
93 .PHONY: upload-coverage .coverage.el pyflakes count-lines
94 .PHONY: check-memory check-memory-once check-speed check-grid
95 .PHONY: repl test-darcs-boringfile test-clean clean find-trailing-spaces
96
97 .coverage.el: .coverage
98         $(PYTHON) misc/coding_tools/coverage2el.py
99
100
101 code-checks: build version-and-path check-interfaces check-miscaptures -find-trailing-spaces -check-umids pyflakes
102
103 version-and-path:
104         $(TAHOE) --version-and-path
105
106 check-interfaces:
107         $(TAHOE) @misc/coding_tools/check-interfaces.py 2>&1 |tee violations.txt
108         @echo
109
110 check-miscaptures:
111         $(PYTHON) misc/coding_tools/check-miscaptures.py $(SOURCES) 2>&1 |tee miscaptures.txt
112         @echo
113
114 pyflakes:
115         @$(PYTHON) -OOu `which pyflakes` $(SOURCES) |sort |uniq
116         @echo
117
118 check-umids:
119         $(PYTHON) misc/coding_tools/check-umids.py `find $(SOURCES) -name '*.py' -not -name 'old.py'`
120         @echo
121
122 -check-umids:
123         -$(PYTHON) misc/coding_tools/check-umids.py `find $(SOURCES) -name '*.py' -not -name 'old.py'`
124         @echo
125
126 doc-checks: check-rst
127
128 check-rst:
129         @for x in `find *.rst docs -name "*.rst"`; do rst2html -v $${x} >/dev/null; done 2>&1 |grep -v 'Duplicate implicit target name:'
130         @echo
131
132 count-lines:
133         @echo -n "files: "
134         @find src -name '*.py' |grep -v /build/ |wc -l
135         @echo -n "lines: "
136         @cat `find src -name '*.py' |grep -v /build/` |wc -l
137         @echo -n "TODO: "
138         @grep TODO `find src -name '*.py' |grep -v /build/` | wc -l
139         @echo -n "XXX: "
140         @grep XXX `find src -name '*.py' |grep -v /build/` | wc -l
141
142 check-memory: .built
143         rm -rf _test_memory
144         $(TAHOE) @src/allmydata/test/check_memory.py upload
145         $(TAHOE) @src/allmydata/test/check_memory.py upload-self
146         $(TAHOE) @src/allmydata/test/check_memory.py upload-POST
147         $(TAHOE) @src/allmydata/test/check_memory.py download
148         $(TAHOE) @src/allmydata/test/check_memory.py download-GET
149         $(TAHOE) @src/allmydata/test/check_memory.py download-GET-slow
150         $(TAHOE) @src/allmydata/test/check_memory.py receive
151
152 check-memory-once: .built
153         rm -rf _test_memory
154         $(TAHOE) @src/allmydata/test/check_memory.py $(MODE)
155
156 # The check-speed target uses a pre-established client node to run a canned
157 # set of performance tests against a test network that is also
158 # pre-established (probably on a remote machine). Provide it with the path to
159 # a local directory where this client node has been created (and populated
160 # with the necessary FURLs of the test network). This target will start that
161 # client with the current code and then run the tests. Afterwards it will
162 # stop the client.
163 #
164 # The 'sleep 5' is in there to give the new client a chance to connect to its
165 # storageservers, since check_speed.py has no good way of doing that itself.
166
167 check-speed: .built
168         if [ -z '$(TESTCLIENTDIR)' ]; then exit 1; fi
169         @echo "stopping any leftover client code"
170         -$(TAHOE) stop $(TESTCLIENTDIR)
171         $(TAHOE) start $(TESTCLIENTDIR)
172         sleep 5
173         $(TAHOE) @src/allmydata/test/check_speed.py $(TESTCLIENTDIR)
174         $(TAHOE) stop $(TESTCLIENTDIR)
175
176 # The check-grid target also uses a pre-established client node, along with a
177 # long-term directory that contains some well-known files. See the docstring
178 # in src/allmydata/test/check_grid.py to see how to set this up.
179 check-grid: .built
180         if [ -z '$(TESTCLIENTDIR)' ]; then exit 1; fi
181         $(TAHOE) @src/allmydata/test/check_grid.py $(TESTCLIENTDIR) bin/tahoe
182
183 bench-dirnode: .built
184         $(TAHOE) @src/allmydata/test/bench_dirnode.py
185
186 # the provisioning tool runs as a stand-alone webapp server
187 run-provisioning-tool: .built
188         $(TAHOE) @misc/operations_helpers/provisioning/run.py
189
190 # 'make repl' is a simple-to-type command to get a Python interpreter loop
191 # from which you can type 'import allmydata'
192 repl:
193         $(TAHOE) debug repl
194
195 test-git-ignore:
196         $(MAKE)
197         $(PYTHON) misc/build_helpers/test-git-ignore.py
198
199 test-clean:
200         find . |grep -vEe "allfiles.tmp|src/allmydata/_(version|appname).py" |sort >allfiles.tmp.old
201         $(MAKE)
202         $(MAKE) distclean
203         find . |grep -vEe "allfiles.tmp|src/allmydata/_(version|appname).py" |sort >allfiles.tmp.new
204         diff allfiles.tmp.old allfiles.tmp.new
205
206 # It would be nice if 'make clean' deleted any automatically-generated
207 # _version.py too, so that 'make clean; make all' could be useable as a
208 # "what the heck is going on, get me back to a clean state', but we need
209 # 'make clean' to work on non-checkout trees without destroying useful information.
210 # Use 'make distclean' instead to delete all generated files.
211 clean:
212         rm -rf build _trial_temp _test_memory .built
213         rm -f `find src *.egg -name '*.so' -or -name '*.pyc'`
214         rm -rf support dist
215         rm -rf `ls -d *.egg | grep -vEe"setuptools-|setuptools_darcs-|darcsver-"`
216         rm -rf *.pyc
217         rm -rf misc/dependencies/build misc/dependencies/temp
218         rm -rf misc/dependencies/tahoe_deps.egg-info
219         rm -f bin/tahoe bin/tahoe.pyscript
220
221 distclean: clean
222         rm -rf src/allmydata_tahoe.egg-info
223         rm -f src/allmydata/_version.py
224         rm -f src/allmydata/_appname.py
225
226 find-trailing-spaces:
227         $(PYTHON) misc/coding_tools/find-trailing-spaces.py -r $(SOURCES)
228         @echo
229
230 -find-trailing-spaces:
231         -$(PYTHON) misc/coding_tools/find-trailing-spaces.py -r $(SOURCES)
232         @echo
233
234 # The test-desert-island target grabs the tahoe-deps tarball, unpacks it,
235 # does a build, then asserts that the build did not try to download anything
236 # as it ran. Invoke this on a new tree, or after a 'clean', to make sure the
237 # support/lib/ directory is gone.
238
239 fetch-and-unpack-deps:
240         test -f tahoe-deps.tar.gz || wget https://tahoe-lafs.org/source/tahoe-lafs/deps/tahoe-lafs-deps.tar.gz
241         rm -rf tahoe-deps
242         tar xzf tahoe-lafs-deps.tar.gz
243
244 test-desert-island:
245         $(MAKE) fetch-and-unpack-deps
246         $(MAKE) 2>&1 | tee make.out
247         $(PYTHON) misc/build_helpers/check-build.py make.out no-downloads
248
249
250 # TARBALL GENERATION
251 .PHONY: tarballs upload-tarballs
252 tarballs:
253         $(MAKE) make-version
254         $(PYTHON) setup.py sdist --formats=bztar,gztar,zip
255         $(PYTHON) setup.py sdist --sumo --formats=bztar,gztar,zip
256
257 upload-tarballs:
258         @if [ "X${BB_BRANCH}" = "Xmaster" ] || [ "X${BB_BRANCH}" = "X" ]; then for f in dist/allmydata-tahoe-*; do flappclient --furlfile ~/.tahoe-tarball-upload.furl upload-file $$f; done ; else echo not uploading tarballs because this is not trunk but is branch \"${BB_BRANCH}\" ; fi