cleanup tmp dir
[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_TIMEOUT=16
8
9 NPM_INSTALL_FLAGS=-q
10 JASMINE_NODE=   ./node_modules/jasmine-node/bin/jasmine-node
11 PHANTOMJS=      ./node_modules/phantomjs/bin/phantomjs
12 IMAGES= ./images
13 SCREENSHOT_WIDTH=       360 480 640 768 1024 1200 1440 2048
14 PERL_SCRIPTS=   bomb.pl
15 TMP_DIR=        ./logs
16
17 all: check
18
19 clean:
20         rm -f mkws-error.png mkws-error.html images/*.png
21
22 distclean: clean clean-tmp
23         rm -rf node_modules
24
25 clean-tmp:
26         rm -rf ${TMP_DIR}
27         mkdir -p ${TMP_DIR}
28         touch ${TMP_DIR}/.gitkeep
29
30 mkws-complete-syntax-check:
31         ${MAKE} -C../src mkws-complete.min.js
32
33 check: mkws-complete-syntax-check
34         @if [ ! -e node_modules ]; then echo "please run first: make node-modules"; exit 1; fi 
35         ${JASMINE_NODE} --noColor --captureExceptions --forceexit ./spec
36
37 test: check
38
39 terse:
40         $(MIKE) jasmine-node --noColor --captureExceptions --forceexit spec
41
42 phantomjs p:
43         ./bomb.pl --timeout="${PHANTOMJS_TIMEOUT}.5" ${PHANTOMJS} phantom/run-jasmine.js ${PHANTOMJS_URL} ${PHANTOMJS_TIMEOUT}
44
45 screenshot:
46         ${PHANTOMJS} phantom/screenshot.js ${PHANTOMJS_URL} ${IMAGES}/screenshot.png 1200 1000
47
48 screenshot-mkws:
49         for i in ${SCREENSHOT_WIDTH}; do \
50             ${PHANTOMJS} phantom/screenshot.js http://mkws.indexdata.com ${IMAGES}/mkws-$$i.png $$i 1000 &  \
51         done; wait
52         ls -l ${IMAGES}
53
54 screenshot-indexdata:
55         for i in ${SCREENSHOT_WIDTH}; do \
56             ${PHANTOMJS} phantom/screenshot.js http://www.indexdata.com ${IMAGES}/indexdata-$$i.png $$i 1000 &  \
57         done; wait
58         ls -l ${IMAGES}
59
60 jsbeautifier jsb indent:
61         for i in package.json ./spec*/*.js ./js/*.js ./phantom/*.js; do \
62           jsbeautifier -j $$i > $@.tmp && mv -f $@.tmp $$i; \
63         done
64
65 perltidy:
66         @ls ${PERL_SCRIPTS} | xargs -n1 -P16 perl -c 2>/dev/null
67         @ls ${PERL_SCRIPTS} | xargs -n2 -P8 perltidy -b
68
69
70 node_modules node-modules:
71         npm install ${NPM_INSTALL_FLAGS}
72
73 help:
74         @echo "make [ all | check | clean | distclean ]"
75         @echo "     [ phantomjs | screenshot ]"
76         @echo "     [ jsbeautifier | perltidy ]"
77         @echo "     [ node-modules ]"
78         @echo ""
79         @echo "DEBUG=1 make phantomjs PHANTOMJS_TIMEOUT=8 PHANTOMJS_URL=https://mkws-dev.indexdata.com/jasmine-popup.html"
80