Merge remote branch 'origin/MKWS-229'
[mkws-moved-to-github.git] / test / Makefile
index 5f059cc..57b5c46 100644 (file)
@@ -1,37 +1,59 @@
-# Copyright (c) 2013 IndexData ApS. http://indexdata.com
+# Copyright (c) 2013-2014 IndexData ApS. http://indexdata.com
 
 # For running on Mike's local install of node.js
 MIKE = PATH=$$PATH:/usr/local/lib/node-v0.10.24-linux-x64/bin
+
+#PHANTOMJS_URL=https://mkws-dev.indexdata.com/jasmine-popup.html       
+PHANTOMJS_URL=http://localhost:4040/jasmine-local-popup.html
+PHANTOMJS_TIMEOUT=16
+
 NPM_INSTALL_FLAGS=-q
+JASMINE_NODE=  ./node_modules/jasmine-node/bin/jasmine-node
 PHANTOMJS=     ./node_modules/phantomjs/bin/phantomjs
-PHANTOMJS_URL= https://mkws-dev.indexdata.com/jasmine-popup.html       
-PHANTOMJS_TIMEOUT=     12      
 IMAGES=        ./images
 SCREENSHOT_WIDTH=      360 480 640 768 1024 1200 1440 2048
+PERL_SCRIPTS=  bin/bomb.pl
+TMP_DIR=       ./logs
+APACHE_HTTPD:= $(shell env PATH=$$PATH:/usr/sbin which apache2 httpd false | head -1 )
 
 all: check
 
 clean:
-       rm -f mkws-error.png mkws-error.html images/*.png
+       rm -f mkws-error.png mkws-error.html 
+       rm -f images/*.png
 
-distclean: clean
+distclean: clean clean-tmp clean-error
        rm -rf node_modules
+       rm -f ${TMP_DIR}/jasmine-dev
+
+clean-error:
+       rm -f mkws-error.png.* mkws-error.html.*
+
+clean-tmp:
+       rm -rf ${TMP_DIR}
+       mkdir -p ${TMP_DIR}
+       touch ${TMP_DIR}/.gitkeep
 
 mkws-complete-syntax-check:
-       ${MAKE} -C../tools/htdocs $@
+       ${MAKE} -C../tools/htdocs mkws-complete.min.js
 
 check: mkws-complete-syntax-check
        @if [ ! -e node_modules ]; then echo "please run first: make node-modules"; exit 1; fi 
-       jasmine-node --noColor --captureExceptions --forceexit ./spec
-       jasmine-node --noColor --captureExceptions --forceexit ./spec-sp
+       ${JASMINE_NODE} --noColor --captureExceptions --forceexit ./spec
 
 test: check
 
 terse:
        $(MIKE) jasmine-node --noColor --captureExceptions --forceexit spec
 
-phantomjs:
-       ${PHANTOMJS} phantom/evaluate.js ${PHANTOMJS_URL} ${PHANTOMJS_TIMEOUT}
+phantomjs p: apache-stop apache-start _phantomjs 
+       ${MAKE} apache-stop
+
+_phantomjs:
+       perl ./bin/bomb.pl --timeout="${PHANTOMJS_TIMEOUT}.5" ${PHANTOMJS} phantom/run-jasmine.js ${PHANTOMJS_URL} ${PHANTOMJS_TIMEOUT}
+
+mike-test:
+       $(MAKE) _phantomjs PHANTOMJS_URL=http://x.example.indexdata.com/jasmine-popup.html
 
 screenshot:
        ${PHANTOMJS} phantom/screenshot.js ${PHANTOMJS_URL} ${IMAGES}/screenshot.png 1200 1000
@@ -49,15 +71,37 @@ screenshot-indexdata:
        ls -l ${IMAGES}
 
 jsbeautifier jsb indent:
-       for i in ./spec*/*.js ./js/*.js ./phantom/*.js; do \
+       for i in package.json ./spec*/*.js ./js/*.js ./phantom/*.js; do \
          jsbeautifier -j $$i > $@.tmp && mv -f $@.tmp $$i; \
        done
 
-node-modules: node_modules
-node_modules:
-       npm install ${NPM_INSTALL_FLAGS} jQuery xmlhttprequest jsdom request jasmine-node phantomjs
+perltidy:
+       @ls ${PERL_SCRIPTS} | xargs -n1 -P16 perl -c 2>/dev/null
+       @ls ${PERL_SCRIPTS} | xargs -n2 -P8 perltidy -b
+
+
+node_modules node-modules:
+       npm install ${NPM_INSTALL_FLAGS}
+
+apache-start:
+       bin/apache-template-update
+       ${APACHE_HTTPD} -f `pwd`/${TMP_DIR}/jasmine-dev
+
+apache-stop:
+       @-if [ -e ${TMP_DIR}/mkws-jasmine.pid ]; then \
+          kill `cat ${TMP_DIR}/mkws-jasmine.pid`; \
+       else \
+          killall apache2 2> /dev/null; \
+       fi
+       @sleep 0.3
+       rm -f ${TMP_DIR}/mkws-jasmine.pid
 
 help:
        @echo "make [ all | check | clean | distclean ]"
        @echo "     [ phantomjs | screenshot ]"
-       @echo "     [ jsbeautifier | node-modules ]"
+       @echo "     [ jsbeautifier | perltidy ]"
+       @echo "     [ node-modules ]"
+       @echo "     [ apache-stop apache-start ]"
+       @echo ""
+       @echo "DEBUG=1 make phantomjs PHANTOMJS_TIMEOUT=12 PHANTOMJS_URL=${PHANTOMJS_URL}"
+