update <title>
[mkws-moved-to-github.git] / test / Makefile
1 # Copyright (c) 2013-2014 Index Data 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 APACHE_PORT:= $(shell echo $${APACHE_PORT-4040})
7
8 #PHANTOMJS_URL=https://mkws-dev.indexdata.com/jasmine-popup.html
9 PHANTOMJS_PATH=jasmine-local-popup.html
10 PHANTOMJS_URL=http://localhost:${APACHE_PORT}/${PHANTOMJS_PATH}
11 PHANTOMJS_TIMEOUT ?= 30
12 PHANTOMJS_FLAGS ?= --ignore-ssl-errors=true
13
14 NPM_INSTALL_FLAGS=-q
15 JASMINE_NODE=   ./node_modules/jasmine-node/bin/jasmine-node
16 PHANTOMJS=      ./node_modules/phantomjs/bin/phantomjs
17 IMAGES= ./images
18 SCREENSHOT_WIDTH=       360 480 640 768 1024 1200 1440 2048
19 PERL_SCRIPTS=   bin/bomb.pl
20 TMP_DIR=        ./logs
21 APACHE_HTTPD:=  $(shell env PATH=$$PATH:/usr/sbin which apache2 httpd false | head -1 )
22 APACHE_PORT ?= 4040
23
24 all: check
25
26 clean:
27         rm -f mkws-error.png mkws-error.html
28         rm -f images/*.png
29         ${MAKE} -C./widgets $@
30
31 distclean: apache-stop clean clean-tmp clean-error
32         rm -rf node_modules
33         rm -f libexec
34
35 clean-error:
36         rm -f mkws-error.png.* mkws-error.html.*
37
38 clean-tmp:
39         rm -rf ${TMP_DIR}
40         mkdir -p ${TMP_DIR}
41         touch ${TMP_DIR}/.gitkeep
42
43 mkws-complete-syntax-check:
44         ${MAKE} -C../src ../tools/htdocs/mkws-complete.min.js
45
46 check check-js: node-modules mkws-complete-syntax-check
47         ${JASMINE_NODE} --noColor --captureExceptions --forceexit ./spec
48
49 check-dev: node-modules mkws-complete-syntax-check
50         ${JASMINE_NODE} --noColor --captureExceptions --forceexit ./spec-dev
51
52 check-node-installation:
53         @if [ ! -e node_modules ]; then \
54             echo "==> please run first: make node-modules"; \
55             echo ""; \
56             exit 1; \
57         fi
58
59 test: check
60
61 terse:
62         $(MIKE) jasmine-node --noColor --captureExceptions --forceexit spec
63
64 phantomjs p: check-js apache-stop apache-start _phantomjs
65         ${MAKE} apache-stop
66
67 _phantomjs:
68         ./bin/bomb --timeout="${PHANTOMJS_TIMEOUT}.5" -- ${PHANTOMJS} ${PHANTOMJS_FLAGS} phantom/run-jasmine.js ${PHANTOMJS_URL} ${PHANTOMJS_TIMEOUT}
69
70 phantomjs-all p-all:
71         ${MAKE} phantomjs PHANTOMJS_PATH=jasmine-local-popup.html
72         ${MAKE} phantomjs PHANTOMJS_PATH=jasmine-popup.html?lang=de
73         ${MAKE} phantomjs PHANTOMJS_PATH=jasmine-cms-popup.html?lang=en
74         ${MAKE} phantomjs PHANTOMJS_PATH=jasmine.html?lang=da
75
76 mike-test:
77         $(MAKE) _phantomjs PHANTOMJS_URL=http://x.example.indexdata.com/jasmine-popup.html
78
79 screenshot:
80         ${PHANTOMJS} phantom/screenshot.js ${PHANTOMJS_URL} ${IMAGES}/screenshot.png 1200 1000
81
82 screenshot-mkws:
83         for i in ${SCREENSHOT_WIDTH}; do \
84             ${PHANTOMJS} phantom/screenshot.js http://mkws.indexdata.com ${IMAGES}/mkws-$$i.png $$i 1000 &  \
85         done; wait
86         ls -l ${IMAGES}
87
88 screenshot-indexdata:
89         for i in ${SCREENSHOT_WIDTH}; do \
90             ${PHANTOMJS} phantom/screenshot.js http://www.indexdata.com ${IMAGES}/indexdata-$$i.png $$i 1000 &  \
91         done; wait
92         ls -l ${IMAGES}
93
94 screenshots: check
95         ${MAKE} -C ./widgets $@
96
97 jsbeautifier jsb indent:
98         for i in package.json ./spec*/*.js ./js/*.js ./phantom/*.js; do \
99           jsbeautifier -j $$i > $@.tmp && mv -f $@.tmp $$i; \
100         done
101
102 perltidy:
103         @ls ${PERL_SCRIPTS} | xargs -n1 -P16 perl -c 2>/dev/null
104         @ls ${PERL_SCRIPTS} | xargs -n2 -P8 perltidy -b
105
106
107 node_modules node-modules:
108         npm install ${NPM_INSTALL_FLAGS}
109
110 apache-start:
111         bin/apache-template-update
112         umask 002; ${APACHE_HTTPD} -f `pwd`/${TMP_DIR}/jasmine-dev-${APACHE_PORT}.conf
113
114 APACHE_PID_FILE=${TMP_DIR}/mkws-jasmine-${APACHE_PORT}.pid
115 apache-stop:
116         @-if [ -e ${APACHE_PID_FILE} ]; then \
117            kill `cat ${APACHE_PID_FILE}`; \
118         else \
119            killall ${APACHE_HTTPD} 2> /dev/null; \
120         fi
121         @sleep 0.6
122         rm -f ${APACHE_PID_FILE}
123
124 help:
125         @echo "make [ all | check | check-dev | clean | distclean ]"
126         @echo "     [ phantomjs | phantomjs-all ]"
127         @echo "     [ jsbeautifier | perltidy | screenshot ]"
128         @echo "     [ screenshots ]"
129         @echo "     [ node-modules ]"
130         @echo "     [ apache-stop apache-start ]"
131         @echo ""
132         @echo "Examples: "
133         @echo ""
134         @echo "make phantomjs PHANTOMJS_PATH=${PHANTOMJS_PATH}"
135         @echo "DEBUG=0 APACHE_PORT=5050 make -s phantomjs PHANTOMJS_TIMEOUT=16 PHANTOMJS_PATH=${PHANTOMJS_PATH}"
136         @echo "DEBUG=2 make phantomjs PHANTOMJS_TIMEOUT=12 PHANTOMJS_URL=${PHANTOMJS_URL}"
137         @echo ""
138         @echo "make APACHE_PORT=5050 apache-start"
139         @echo "make phantomjs-all"
140         @echo ""