From 4ed11dba4c5469fd7e73f38a4071d824918837e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jannis=20Mo=C3=9Fhammer?= Date: Mon, 17 Jun 2013 17:17:15 +0200 Subject: [PATCH] Add 'public' symlink creation to runtests Runtest now creates a symlink to the public folder when it doesn't exist, allowing the built-in server to access the js files without too much hassle refs #4303 refs #4315 --- test/frontend/i2w-config.js | 51 +++++++++++++++++++++++++++++++++++++ test/frontend/runtests | 11 ++++++++ 2 files changed, 62 insertions(+) diff --git a/test/frontend/i2w-config.js b/test/frontend/i2w-config.js index 7d54a1a00..4d72b6d7e 100644 --- a/test/frontend/i2w-config.js +++ b/test/frontend/i2w-config.js @@ -93,6 +93,14 @@ if (path === null) var openFromBase = function(url, options) { return copenFrom.apply(casper,[this.getBaseURL(url), options]); }; + casper.on('remote.message', function(message) { + console.log(message); + }); + + casper.on('page.error', function(message, trace) { + console.error(message, JSON.stringify(trace)); + }); + exports.getTestEnv = function() { casper.getBaseURL = getBaseURL; @@ -102,6 +110,49 @@ if (path === null) return casper; }; + exports.setupRequireJs = function(libraries) { + if (typeof libraries === "undefined") { + libraries = { + jquery: 'vendor/jquery-1.8.3', + bootstrap: 'vendor/bootstrap.min', + eve: 'vendor/raphael/eve' + }; + } else { + libraries = libraries || {}; + libraries.logging = 'icinga/util/logging'; + libraries.jquery = 'vendor/jquery-1.8.3'; + libraries["modules/list"] = "/moduleMock"; + if (libraries.bootstrap || libraries.icinga) { + libraries.bootstrap = 'vendor/bootstrap.min'; + libraries.history = 'vendor/history'; + libraries.eve = 'vendor/raphael/eve'; + libraries.raphael = 'vendor/raphael/raphael.amd'; + libraries["raphael.core"] = 'vendor/raphael/raphael.core'; + libraries["raphael.svg"] = 'vendor/raphael/raphael.svg'; + libraries["raphael.vml"] = 'vendor/raphael/raphael.vml'; + } + if (libraries.ace) { + libraries.ace = 'vendor/ace/ace'; + } + } + var bootstrap = libraries.icinga; + delete(libraries.icinga); + requirejs.config({ + baseUrl: window.base_url + '/js', + paths: libraries + }); + if (bootstrap) { + + requirejs(['jquery', 'history']); + requirejs(['bootstrap']); + requirejs(['icinga/icinga'], function (Icinga) { + window.$ = $; + window.jQuery = $; + window.Icinga = Icinga; + window.History = History; + }); + } + }; })(); diff --git a/test/frontend/runtests b/test/frontend/runtests index cb24dd57b..df29ce6e7 100755 --- a/test/frontend/runtests +++ b/test/frontend/runtests @@ -16,6 +16,11 @@ if [ ! -x $CASPER ]; then "Take a look at http://casperjs.org/installation.html to see how the installation works for your system" exit 1 fi; +if [ ! -e "${DIR}/static/public" ]; then + echo "!" + ln -s "${DIR}/../../public" "${DIR}/static/public" +fi; + PARAM="0" for arg in $@;do @@ -108,10 +113,16 @@ if [ "$EXCLUDE" != "" ];then fi FILELIST=`echo $FILELIST | grep -v "$NAME"` fi; + cd $DIR/static +PROC=`ps ax|grep "SimpleHTTPServer 12999"|awk '{ print $1 }'` +if [ "$PROC" != "" ]; then + kill $PROC +fi; python -m SimpleHTTPServer 12999& PID=$! cd $DIR + echo $EXEC $FILELIST $EXEC $FILELIST kill $PID