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