de-couple phantomjs regression test from debian apache setup
[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-local-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=   bin/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 
23         rm -f images/*.png
24
25 distclean: clean clean-tmp clean-error
26         rm -rf node_modules
27         rm -f ${TMP_DIR}/jasmine-dev
28
29 clean-error:
30         rm -f mkws-error.png.* mkws-error.html.*
31
32 clean-tmp:
33         rm -rf ${TMP_DIR}
34         mkdir -p ${TMP_DIR}
35         touch ${TMP_DIR}/.gitignore
36
37 mkws-complete-syntax-check:
38         ${MAKE} -C../src mkws-complete.min.js
39
40 check: mkws-complete-syntax-check
41         @if [ ! -e node_modules ]; then echo "please run first: make node-modules"; exit 1; fi 
42         ${JASMINE_NODE} --noColor --captureExceptions --forceexit ./spec
43
44 test: check
45
46 terse:
47         $(MIKE) jasmine-node --noColor --captureExceptions --forceexit spec
48
49 phantomjs p: apache-stop apache-start _phantomjs apache-stop
50
51 _phantomjs:
52         ./bin/bomb.pl --timeout="${PHANTOMJS_TIMEOUT}.5" ${PHANTOMJS} phantom/run-jasmine.js ${PHANTOMJS_URL} ${PHANTOMJS_TIMEOUT}
53
54 screenshot:
55         ${PHANTOMJS} phantom/screenshot.js ${PHANTOMJS_URL} ${IMAGES}/screenshot.png 1200 1000
56
57 screenshot-mkws:
58         for i in ${SCREENSHOT_WIDTH}; do \
59             ${PHANTOMJS} phantom/screenshot.js http://mkws.indexdata.com ${IMAGES}/mkws-$$i.png $$i 1000 &  \
60         done; wait
61         ls -l ${IMAGES}
62
63 screenshot-indexdata:
64         for i in ${SCREENSHOT_WIDTH}; do \
65             ${PHANTOMJS} phantom/screenshot.js http://www.indexdata.com ${IMAGES}/indexdata-$$i.png $$i 1000 &  \
66         done; wait
67         ls -l ${IMAGES}
68
69 jsbeautifier jsb indent:
70         for i in package.json ./spec*/*.js ./js/*.js ./phantom/*.js; do \
71           jsbeautifier -j $$i > $@.tmp && mv -f $@.tmp $$i; \
72         done
73
74 perltidy:
75         @ls ${PERL_SCRIPTS} | xargs -n1 -P16 perl -c 2>/dev/null
76         @ls ${PERL_SCRIPTS} | xargs -n2 -P8 perltidy -b
77
78
79 node_modules node-modules:
80         npm install ${NPM_INSTALL_FLAGS}
81
82 apache-start:
83         bin/apache-template-update
84         ${APACHE_HTTPD} -f `pwd`/${TMP_DIR}/jasmine-dev
85         
86 apache-stop:
87         @-if [ -e ${TMP_DIR}/mkws-jasmine.pid ]; then \
88            kill `cat ${TMP_DIR}/mkws-jasmine.pid`; \
89         else \
90            killall apache2 2> /dev/null; \
91         fi
92         @sleep 0.3
93
94 help:
95         @echo "make [ all | check | clean | distclean ]"
96         @echo "     [ phantomjs | screenshot ]"
97         @echo "     [ jsbeautifier | perltidy ]"
98         @echo "     [ node-modules ]"
99         @echo "     [ apache-stop apache-start ]"
100         @echo ""
101         @echo "DEBUG=1 make phantomjs PHANTOMJS_TIMEOUT=8 PHANTOMJS_URL=${PHANTOMJS_URL}"
102