a1142b12ce80a713e934eaccf38bda8d20b5cdf0
[mkws-moved-to-github.git] / test / Makefile
1 # Copyright (c) 2013-2014 IndexData ApS. http://indexdata.com
2
3 # For running on Mike's local install of node.js
4 MIKE = PATH=$$PATH:/usr/local/lib/node-v0.10.24-linux-x64/bin
5
6 #PHANTOMJS_URL=https://mkws-dev.indexdata.com/jasmine-popup.html        
7 PHANTOMJS_URL=http://localhost:4040/jasmine-popup.html
8 PHANTOMJS_TIMEOUT=16
9
10 NPM_INSTALL_FLAGS=-q
11 JASMINE_NODE=   ./node_modules/jasmine-node/bin/jasmine-node
12 PHANTOMJS=      ./node_modules/phantomjs/bin/phantomjs
13 IMAGES= ./images
14 SCREENSHOT_WIDTH=       360 480 640 768 1024 1200 1440 2048
15 PERL_SCRIPTS=   bomb.pl
16 TMP_DIR=        ./logs
17 APACHE_HTTPD=   /usr/sbin/apache2
18
19 all: check
20
21 clean:
22         rm -f mkws-error.png mkws-error.html images/*.png
23
24 distclean: clean clean-tmp
25         rm -rf node_modules
26         rm -f ${TMP_DIR}/jasmine-dev
27
28 clean-tmp:
29         rm -rf ${TMP_DIR}
30         mkdir -p ${TMP_DIR}
31         touch ${TMP_DIR}/.gitkeep
32
33 mkws-complete-syntax-check:
34         ${MAKE} -C../src mkws-complete.min.js
35
36 check: mkws-complete-syntax-check
37         @if [ ! -e node_modules ]; then echo "please run first: make node-modules"; exit 1; fi 
38         ${JASMINE_NODE} --noColor --captureExceptions --forceexit ./spec
39
40 test: check
41
42 terse:
43         $(MIKE) jasmine-node --noColor --captureExceptions --forceexit spec
44
45 phantomjs p: apache-stop apache-start
46         ./bomb.pl --timeout="${PHANTOMJS_TIMEOUT}.5" ${PHANTOMJS} phantom/run-jasmine.js ${PHANTOMJS_URL} ${PHANTOMJS_TIMEOUT}
47         ${MAKE} apache-stop
48
49 screenshot:
50         ${PHANTOMJS} phantom/screenshot.js ${PHANTOMJS_URL} ${IMAGES}/screenshot.png 1200 1000
51
52 screenshot-mkws:
53         for i in ${SCREENSHOT_WIDTH}; do \
54             ${PHANTOMJS} phantom/screenshot.js http://mkws.indexdata.com ${IMAGES}/mkws-$$i.png $$i 1000 &  \
55         done; wait
56         ls -l ${IMAGES}
57
58 screenshot-indexdata:
59         for i in ${SCREENSHOT_WIDTH}; do \
60             ${PHANTOMJS} phantom/screenshot.js http://www.indexdata.com ${IMAGES}/indexdata-$$i.png $$i 1000 &  \
61         done; wait
62         ls -l ${IMAGES}
63
64 jsbeautifier jsb indent:
65         for i in package.json ./spec*/*.js ./js/*.js ./phantom/*.js; do \
66           jsbeautifier -j $$i > $@.tmp && mv -f $@.tmp $$i; \
67         done
68
69 perltidy:
70         @ls ${PERL_SCRIPTS} | xargs -n1 -P16 perl -c 2>/dev/null
71         @ls ${PERL_SCRIPTS} | xargs -n2 -P8 perltidy -b
72
73
74 node_modules node-modules:
75         npm install ${NPM_INSTALL_FLAGS}
76
77 apache-start:
78         bin/apache-template-update
79         ${APACHE_HTTPD} -f `pwd`/${TMP_DIR}/jasmine-dev
80         
81 apache-stop:
82         @-if [ -e ${TMP_DIR}/mkws-jasmine.pid ]; then \
83            kill `cat ${TMP_DIR}/mkws-jasmine.pid`; \
84         else \
85            killall apache2 2> /dev/null; \
86         fi
87         @sleep 0.3
88
89 help:
90         @echo "make [ all | check | clean | distclean ]"
91         @echo "     [ phantomjs | screenshot ]"
92         @echo "     [ jsbeautifier | perltidy ]"
93         @echo "     [ node-modules ]"
94         @echo "     [ apache-stop apache-start ]"
95         @echo ""
96         @echo "DEBUG=1 make phantomjs PHANTOMJS_TIMEOUT=8 PHANTOMJS_URL=${PHANTOMJS_URL}"
97