forked from gabrielfalcao/dead-parrot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
111 lines (99 loc) · 3.45 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# Copyright (C) 2009 Gabriel Falcão <gabriel@nacaolivre.org>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public
# License along with this program; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
ifeq ($(shell echo $$TERM),xterm)
normal := "\e[0m"
red := "\e[1;31m"
green := "\e[1;32m"
yellow := "\e[1;33m"
blue := "\e[1;34m"
white := "\e[1;37m"
else
normal :=
red :=
green :=
yellow :=
blue :=
white :=
endif
nose_command := nosetests --verbosity=2 -s --with-coverage --cover-package=deadparrot.server --cover-package=deadparrot.serialization --cover-package=deadparrot.models
help:
@echo "Available targets are:"
@echo "all build files"
@echo "clean removes unused files"
@echo "functional runs functional tests"
@echo "doctests runs doctests"
@echo "acceptance runs acceptance tests"
@echo "test runs unit tests"
@echo "build build files"
all: build
clean:
@echo "Cleaning up build files..."
@rm -rf build
@echo "Cleaning up *.pyc files..."
@find . -name '*.pyc' -exec rm -rf {} \;
@echo "Cleaning up *.json files..."
@find . -name '*.json' -exec rm -rf {} \;
unit:
@echo "Running unit tests..."
@$(nose_command) tests/unit
functional: clean run_server
@echo "Running functional tests..."
@$(nose_command) tests/functional
doctest:
@echo -ne $(blue)
@echo "Running doctests..."
@echo -ne $(red)
@python -c "import doctest;doctest.testfile('./README.rst', verbose=False, report=True)"
@echo -ne $(green)
@echo "tests passed!"
@echo -ne $(normal)
acceptance:
@echo -ne $(yellow)
@echo "Running acceptance tests (all codes from documentation)..."
@echo -ne $(red)
@python -c "import doctest;doctest.testfile('./docs/serialization.rst', verbose=False, report=True)"
@echo -ne $(green)
@echo "tests passed!"
@echo -ne $(normal)
test: functional unit doctest acceptance
build: clean test
@echo -ne $(yellow)
@echo "Buiding dead-parrot..."
@echo -ne $(red)
@python setup.py build > /dev/null
@echo -ne $(yellow)
@echo "DONE."
@echo -ne $(blue)
@echo "Ensuring that the build is fine ..."
@echo -ne $(red)
@cp -drf tests `pwd`/build/lib/
@cd `pwd`/build/lib/ && nosetests tests && rm -rf tests
@echo -ne $(yellow)
@echo "DONE."
@echo -ne $(white)
@echo "Built successfully."
@echo -ne $(green)
@echo "Get it in `pwd`/build/lib/"
@echo -ne $(normal)
run_server: kill_server
@echo "Running builtin HTTP server ..."
@(cd tests/functional/parrotserver && bob go 2>&1) > log.txt &
@sleep 5
kill_server:
@echo -n "Shutting down builtin HTTP server ..."
@(ps aux | egrep 'bob go' | egrep -v grep | awk '{ print $$2 }' | xargs kill -9 2>&1 | exit 0) > /dev/null
@echo " Done."