]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/blob - Makefile
Makefile: consistently use 'tahoe debug trial' to run tests. refs #1296
[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 PP=$(shell $(PYTHON) setup.py -q show_pythonpath)
13 RUNPP=$(PYTHON) setup.py run_with_pythonpath
14 TAHOE=$(PYTHON) bin/tahoe
15
16 .PHONY: make-version build
17
18 # The 'darcsver' setup.py command comes in the 'darcsver' package:
19 # http://pypi.python.org/pypi/darcsver It is necessary only if you want to
20 # automatically produce a new _version.py file from the current darcs history.
21 make-version:
22         $(PYTHON) ./setup.py darcsver --count-all-patches
23
24 # We want src/allmydata/_version.py to be up-to-date, but it's a fairly
25 # expensive operation (about 6 seconds on a just-before-0.7.0 tree, probably
26 # because of the 332 patches since the last tag), and we've removed the need
27 # for an explicit 'build' step by removing the C code from src/allmydata and
28 # by running everything in place. It would be neat to do:
29 #
30 #src/allmydata/_version.py: _darcs/patches
31 #       $(MAKE) make-version
32 #
33 # since that would update the embedded version string each time new darcs
34 # patches were pulled, but without an obligatory 'build' step this rule
35 # wouldn't be run frequently enough anyways.
36 #
37 # So instead, I'll just make sure that we update the version at least once
38 # when we first start using the tree, and again whenever an explicit
39 # 'make-version' is run, since then at least the developer has some means to
40 # update things. It would be nice if 'make clean' deleted any
41 # automatically-generated _version.py too, so that 'make clean; make all'
42 # could be useable as a "what the heck is going on, get me back to a clean
43 # state', but we need 'make clean' to work on non-darcs trees without
44 # destroying useful information.
45
46 .built:
47         $(MAKE) build
48
49 src/allmydata/_version.py:
50         $(MAKE) make-version
51
52 # c.f. ticket #455, there is a problem in the intersection of setuptools,
53 # twisted's setup.py, and nevow's setup.py . A Tahoe build, to satisfy its
54 # dependencies, may try to build both Twisted and Nevow. If both of these
55 # occur during the same invocation of 'setup.py develop', then the Nevow
56 # build will fail with an "ImportError: No module named components". Running
57 # the build a second time will succeed. Until there is a new version of
58 # setuptools which properly sandboxes sys.modules (or a new version of nevow
59 # which doesn't import twisted during its build, or a new version of twisted
60 # which doesn't import itself during its build), we just build tahoe twice
61 # and ignore the errors from the first pass. Updated 16-Sep-2008: now we need
62 # three invocations.
63
64 build: src/allmydata/_version.py
65         $(PYTHON) setup.py build
66         touch .built
67
68 # 'make install' will do the following:
69 #   build+install tahoe (probably to /usr/lib/pythonN.N/site-packages)
70 # 'make install PREFIX=/usr/local/stow/tahoe-N.N' will do the same, but to
71 # a different location
72
73 install: src/allmydata/_version.py
74 ifdef PREFIX
75         mkdir -p $(PREFIX)
76         $(PYTHON) ./setup.py install --single-version-externally-managed \
77            --prefix=$(PREFIX) --record=./tahoe.files
78 else
79         $(PYTHON) ./setup.py install --single-version-externally-managed
80 endif
81
82
83 # TESTING
84
85 .PHONY: signal-error-deps test test-coverage quicktest quicktest-coverage
86 .PHONY: coverage-output get-old-coverage-coverage coverage-delta-output
87
88
89 signal-error-deps:
90         @echo
91         @echo
92         @echo "ERROR: Not all of Tahoe's dependencies are in place.  Please see docs/install.html for help on installing dependencies."
93         @echo
94         @echo
95         exit 1
96
97 check-auto-deps:
98         $(PYTHON) setup.py -q check_auto_deps || $(MAKE) signal-error-deps
99
100 .checked-deps:
101         $(MAKE) check-auto-deps
102         touch .checked-deps
103
104 # you can use 'make test TEST=allmydata.test.test_introducer' to run just
105 # test_introducer. TEST=allmydata.test.test_client.Basic.test_permute works
106 # too.
107 TEST=allmydata
108
109 # use 'make test TRIALARGS=--reporter=bwverbose' from buildbot, to
110 # suppress the ansi color sequences
111
112 test: build src/allmydata/_version.py
113         $(PYTHON) setup.py test $(TRIALARGS) -s $(TEST)
114
115 fuse-test: .built .checked-deps
116         $(RUNPP) -d contrib/fuse -p -c runtests.py
117
118 test-coverage: build src/allmydata/_version.py
119         rm -f .coverage
120         $(TAHOE) debug trial --reporter=bwverbose-coverage $(TEST)
121
122 quicktest:
123         $(TAHOE) debug trial $(TRIALARGS) $(TEST)
124
125 # code-coverage: install the "coverage" package from PyPI, do "make
126 # quicktest-coverage" to do a unit test run with coverage-gathering enabled,
127 # then use "make coverate-output-text" for a brief report, or "make
128 # coverage-output" for a pretty HTML report. Also see "make .coverage.el" and
129 # misc/coding_tools/coverage.el for emacs integration.
130
131 quicktest-coverage:
132         rm -f .coverage
133         $(TAHOE) debug trial --reporter=bwverbose-coverage $(TEST)
134 # on my laptop, "quicktest" takes 239s, "quicktest-coverage" takes 304s
135
136 # --include appeared in coverage-3.4
137 COVERAGE_OMIT=--include '$(CURDIR)/src/allmydata/*' --omit '$(CURDIR)/src/allmydata/test/*'
138 coverage-output:
139         rm -rf coverage-html
140         coverage html -i -d coverage-html $(COVERAGE_OMIT)
141         cp .coverage coverage-html/coverage.data
142         @echo "now point your browser at coverage-html/index.html"
143
144 ## use these two targets to compare this coverage against the previous run.
145 ## The deltas only work if the old test was run in the same directory, since
146 ## it compares absolute filenames.
147 #get-old-figleaf-coverage:
148 #       wget --progress=dot -O old.figleaf http://allmydata.org/tahoe-figleaf/current/figleaf.pickle
149 #
150 #figleaf-delta-output:
151 #       $(RUNPP) -p -c "misc/figleaf2html -d coverage-html -r src -x misc/figleaf.excludes -o old.figleaf"
152 #       cp .figleaf coverage-html/figleaf.pickle
153 #       @echo "now point your browser at coverage-html/index.html"
154
155 .PHONY: upload-coverage .coverage.el pyflakes count-lines
156 .PHONY: check-memory check-memory-once check-speed check-grid
157 .PHONY: repl test-darcs-boringfile test-clean clean find-trailing-spaces
158
159 .coverage.el: .coverage
160         $(PYTHON) misc/coding_tools/coverage2el.py
161
162 # 'upload-coverage' is meant to be run with an UPLOAD_TARGET=host:/dir setting
163 ifdef UPLOAD_TARGET
164
165 ifndef UPLOAD_HOST
166 $(error UPLOAD_HOST must be set when using UPLOAD_TARGET)
167 endif
168 ifndef COVERAGEDIR
169 $(error COVERAGEDIR must be set when using UPLOAD_TARGET)
170 endif
171
172 upload-coverage:
173         rsync -a coverage-html/ $(UPLOAD_TARGET)
174         ssh $(UPLOAD_HOST) make update-tahoe-coverage COVERAGEDIR=$(COVERAGEDIR)
175 else
176 upload-coverage:
177         echo "this target is meant to be run with UPLOAD_TARGET=host:/path/"
178         false
179 endif
180
181
182 pyflakes:
183         $(PYTHON) -OOu `which pyflakes` src/allmydata |sort |uniq
184 check-umids:
185         $(PYTHON) misc/coding_tools/check-umids.py `find src/allmydata -name '*.py'`
186
187 count-lines:
188         @echo -n "files: "
189         @find src -name '*.py' |grep -v /build/ |wc --lines
190         @echo -n "lines: "
191         @cat `find src -name '*.py' |grep -v /build/` |wc --lines
192         @echo -n "TODO: "
193         @grep TODO `find src -name '*.py' |grep -v /build/` | wc --lines
194
195 check-memory: .built
196         rm -rf _test_memory
197         $(RUNPP) -p -c "src/allmydata/test/check_memory.py upload"
198         $(RUNPP) -p -c "src/allmydata/test/check_memory.py upload-self"
199         $(RUNPP) -p -c "src/allmydata/test/check_memory.py upload-POST"
200         $(RUNPP) -p -c "src/allmydata/test/check_memory.py download"
201         $(RUNPP) -p -c "src/allmydata/test/check_memory.py download-GET"
202         $(RUNPP) -p -c "src/allmydata/test/check_memory.py download-GET-slow"
203         $(RUNPP) -p -c "src/allmydata/test/check_memory.py receive"
204
205 check-memory-once: .built
206         rm -rf _test_memory
207         $(RUNPP) -p -c "src/allmydata/test/check_memory.py $(MODE)"
208
209 # The check-speed target uses a pre-established client node to run a canned
210 # set of performance tests against a test network that is also
211 # pre-established (probably on a remote machine). Provide it with the path to
212 # a local directory where this client node has been created (and populated
213 # with the necessary FURLs of the test network). This target will start that
214 # client with the current code and then run the tests. Afterwards it will
215 # stop the client.
216 #
217 # The 'sleep 5' is in there to give the new client a chance to connect to its
218 # storageservers, since check_speed.py has no good way of doing that itself.
219
220 check-speed: .built
221         if [ -z '$(TESTCLIENTDIR)' ]; then exit 1; fi
222         @echo "stopping any leftover client code"
223         -$(PYTHON) bin/tahoe stop $(TESTCLIENTDIR)
224         $(PYTHON) bin/tahoe start $(TESTCLIENTDIR)
225         sleep 5
226         $(PYTHON) src/allmydata/test/check_speed.py $(TESTCLIENTDIR)
227         $(PYTHON) bin/tahoe stop $(TESTCLIENTDIR)
228
229 # The check-grid target also uses a pre-established client node, along with a
230 # long-term directory that contains some well-known files. See the docstring
231 # in src/allmydata/test/check_grid.py to see how to set this up.
232 check-grid: .built
233         if [ -z '$(TESTCLIENTDIR)' ]; then exit 1; fi
234         $(PYTHON) src/allmydata/test/check_grid.py $(TESTCLIENTDIR) bin/tahoe
235
236 bench-dirnode: .built
237         $(RUNPP) -p -c src/allmydata/test/bench_dirnode.py
238
239 # 'make repl' is a simple-to-type command to get a Python interpreter loop
240 # from which you can type 'import allmydata'
241 repl:
242         $(RUNPP) -p
243
244 test-darcs-boringfile:
245         $(MAKE)
246         $(PYTHON) misc/build_helpers/test-darcs-boringfile.py
247
248 test-clean:
249         find . |grep -vEe "_darcs|allfiles.tmp|src/allmydata/_(version|appname).py" |sort >allfiles.tmp.old
250         $(MAKE)
251         $(MAKE) clean
252         find . |grep -vEe "_darcs|allfiles.tmp|src/allmydata/_(version|appname).py" |sort >allfiles.tmp.new
253         diff allfiles.tmp.old allfiles.tmp.new
254
255 clean:
256         rm -rf build _trial_temp _test_memory .checked-deps .built
257         rm -f `find src *.egg -name '*.so' -or -name '*.pyc'`
258         rm -rf src/allmydata_tahoe.egg-info
259         rm -rf support dist
260         rm -rf `ls -d *.egg | grep -vEe"setuptools-|setuptools_darcs-|darcsver-"`
261         rm -rf *.pyc
262         rm -rf misc/dependencies/build misc/dependencies/temp
263         rm -rf misc/dependencies/tahoe_deps.egg-info
264         rm -f bin/tahoe bin/tahoe.pyscript
265
266 find-trailing-spaces:
267         $(PYTHON) misc/coding_tools/find-trailing-spaces.py -r src
268
269 # The test-desert-island target grabs the tahoe-deps tarball, unpacks it,
270 # does a build, then asserts that the build did not try to download anything
271 # as it ran. Invoke this on a new tree, or after a 'clean', to make sure the
272 # support/lib/ directory is gone.
273
274 fetch-and-unpack-deps:
275         test -f tahoe-deps.tar.gz || wget http://allmydata.org/source/tahoe/deps/tahoe-deps.tar.gz
276         rm -rf tahoe-deps
277         tar xzf tahoe-deps.tar.gz
278
279 test-desert-island:
280         $(MAKE) fetch-and-unpack-deps
281         $(MAKE) 2>&1 | tee make.out
282         $(PYTHON) misc/build_helpers/check-build.py make.out no-downloads
283
284
285 # TARBALL GENERATION
286 .PHONY: tarballs upload-tarballs
287 tarballs:
288         $(MAKE) make-version
289         $(PYTHON) setup.py sdist --formats=bztar,gztar,zip
290         $(PYTHON) setup.py sdist --sumo --formats=bztar,gztar,zip
291
292 upload-tarballs:
293         @if [ "X${BB_BRANCH}" == "Xtrunk" ] || [ "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
294
295 # DEBIAN PACKAGING
296
297 VER=$(shell $(PYTHON) misc/build_helpers/get-version.py)
298 DEBCOMMENTS="'make deb' build"
299
300 show-version:
301         @echo $(VER)
302 show-pp:
303         @echo $(PP)
304
305 .PHONY: setup-deb deb-ARCH is-known-debian-arch
306 .PHONY: deb-etch deb-lenny deb-sid
307 .PHONY: deb-edgy deb-feisty deb-gutsy deb-hardy deb-intrepid deb-jaunty
308
309 # we use misc/debian_helpers/$TAHOE_ARCH/debian
310
311 deb-etch:      # py2.4
312         $(MAKE) deb-ARCH ARCH=etch TAHOE_ARCH=etch
313 deb-lenny:     # py2.5
314         $(MAKE) deb-ARCH ARCH=lenny TAHOE_ARCH=lenny
315 deb-sid:
316         $(MAKE) deb-ARCH ARCH=sid TAHOE_ARCH=sid
317
318 deb-edgy:     # py2.4
319         $(MAKE) deb-ARCH ARCH=edgy TAHOE_ARCH=etch
320 deb-feisty:   # py2.5
321         $(MAKE) deb-ARCH ARCH=feisty TAHOE_ARCH=lenny
322 deb-gutsy:    # py2.5
323         $(MAKE) deb-ARCH ARCH=gutsy TAHOE_ARCH=lenny
324 deb-hardy:    # py2.5
325         $(MAKE) deb-ARCH ARCH=hardy TAHOE_ARCH=lenny
326 deb-intrepid: # py2.5
327         $(MAKE) deb-ARCH ARCH=intrepid TAHOE_ARCH=lenny
328 deb-jaunty:   # py2.6
329         $(MAKE) deb-ARCH ARCH=jaunty TAHOE_ARCH=lenny
330
331
332
333 # we know how to handle the following debian architectures
334 KNOWN_DEBIAN_ARCHES := etch lenny sid  edgy feisty gutsy hardy intrepid jaunty
335
336 ifeq ($(findstring x-$(ARCH)-x,$(foreach arch,$(KNOWN_DEBIAN_ARCHES),"x-$(arch)-x")),)
337 is-known-debian-arch:
338         @echo "ARCH must be set when using setup-deb or deb-ARCH"
339         @echo "I know how to handle:" $(KNOWN_DEBIAN_ARCHES)
340         false
341 else
342 is-known-debian-arch:
343         true
344 endif
345
346 ifndef TAHOE_ARCH
347 TAHOE_ARCH=$(ARCH)
348 endif
349
350 setup-deb: is-known-debian-arch
351         rm -f debian
352         ln -s misc/debian_helpers/$(TAHOE_ARCH)/debian debian
353         chmod +x debian/rules
354
355 # etch (current debian stable) has python-simplejson-1.3, which doesn't
356 #  support indent=
357 # sid (debian unstable) currently has python-simplejson 1.7.1
358 # edgy has 1.3, which doesn't support indent=
359 # feisty has 1.4, which supports indent= but emits a deprecation warning
360 # gutsy has 1.7.1
361 #
362 # we need 1.4 or newer
363
364 deb-ARCH: is-known-debian-arch setup-deb
365         fakeroot debian/rules binary
366         @echo
367         @echo "The newly built .deb packages are in the parent directory from here."
368
369 .PHONY: increment-deb-version
370 .PHONY: deb-etch-head deb-lenny-head deb-sid-head
371 .PHONY: deb-edgy-head deb-feisty-head deb-gutsy-head deb-hardy-head deb-intrepid-head deb-jaunty-head
372
373 # The buildbot runs the following targets after each change, to produce
374 # up-to-date tahoe .debs. These steps do not create .debs for anything else.
375
376 increment-deb-version: make-version
377         debchange --newversion $(VER) $(DEBCOMMENTS)
378 deb-etch-head:
379         $(MAKE) setup-deb ARCH=etch TAHOE_ARCH=etch
380         $(MAKE) increment-deb-version
381         fakeroot debian/rules binary
382 deb-lenny-head:
383         $(MAKE) setup-deb ARCH=lenny TAHOE_ARCH=lenny
384         $(MAKE) increment-deb-version
385         fakeroot debian/rules binary
386 deb-sid-head:
387         $(MAKE) setup-deb ARCH=sid TAHOE_ARCH=lenny
388         $(MAKE) increment-deb-version
389         fakeroot debian/rules binary
390
391 deb-edgy-head:
392         $(MAKE) setup-deb ARCH=edgy TAHOE_ARCH=etch
393         $(MAKE) increment-deb-version
394         fakeroot debian/rules binary
395 deb-feisty-head:
396         $(MAKE) setup-deb ARCH=feisty TAHOE_ARCH=lenny
397         $(MAKE) increment-deb-version
398         fakeroot debian/rules binary
399 deb-gutsy-head:
400         $(MAKE) setup-deb ARCH=gutsy TAHOE_ARCH=lenny
401         $(MAKE) increment-deb-version
402         fakeroot debian/rules binary
403 deb-hardy-head:
404         $(MAKE) setup-deb ARCH=hardy TAHOE_ARCH=lenny
405         $(MAKE) increment-deb-version
406         fakeroot debian/rules binary
407 deb-intrepid-head:
408         $(MAKE) setup-deb ARCH=intrepid TAHOE_ARCH=lenny
409         $(MAKE) increment-deb-version
410         fakeroot debian/rules binary
411 deb-jaunty-head:
412         $(MAKE) setup-deb ARCH=jaunty TAHOE_ARCH=lenny
413         $(MAKE) increment-deb-version
414         fakeroot debian/rules binary
415
416 # new experimental debian-packaging-building target
417 .PHONY: EXPERIMENTAL-deb
418 EXPERIMENTAL-deb: is-known-debian-arch
419         $(PYTHON) misc/build_helpers/build-deb.py $(ARCH)