2 # Run instrumented unit tests
4 # set CHROME_BIN to the path to/name of your Google Chrome binary
5 # (default = `which google-chrome`)
6 # set JS_COVERAGE_BIN to the path to/name of your jscoverage binary
7 # (default = `which jscoverage`)
10 SCRIPT_PATH=`readlink -f $0`
12 if [[ "x" == "x$SCRIPT_PATH" ]] ; then
15 DIR=`dirname $SCRIPT_PATH`
18 # programs we need to run
19 if [[ "x" == "x$CHROME_BIN" ]] ; then
20 CHROME_BIN=`which google-chrome || which chromium-browser`
23 if [[ "x$CHROME_BIN" == "x" ]] ; then
24 echo "*** ERROR: google-chrome not found - please make sure it's installed"
25 echo "Then either put it on your PATH or set the CHROME_BIN env variable"
29 if [[ "x" == "x$JSCOVERAGE_BIN" ]] ; then
30 JSCOVERAGE_BIN=`which jscoverage`
33 if [[ "x$JSCOVERAGE_BIN" == "x" ]] ; then
34 echo "*** ERROR: jscoverage not found - please make sure it's installed"
35 echo "Then either put it on your PATH or set the JSCOVERAGE_BIN env variable"
39 # directory for instrumented files
40 if [ -d $DIR/instrumented ] ; then
41 rm -Rf $DIR/instrumented
44 # just instrument the tizen-web-ui-fw file
45 $JSCOVERAGE_BIN --exclude tizen-web-ui-fw-libs.js --exclude jquery.js \
46 $DIR/../../build/tizen-web-ui-fw/latest/js $DIR/instrumented
48 # copy all the unit tests to the instrumented directory
49 cp -a $DIR/../unit-tests/* $DIR/instrumented/
51 # edit links in all index.html test files
52 for file in `find $DIR/instrumented/ -name index.html` ; do
53 # refer to the instrumented tizen-web-ui-fw JS file
54 sed -i -e 's%\.\.\/\.\.\/\.\.\/build\/tizen-web-ui-fw\/latest\/js\/tizen-web-ui-fw\.js%\.\.\/tizen-web-ui-fw\.js%' $file
56 # other files are just one directory further up
57 sed -i -e 's%\.\.\/\.\.\/build%\.\.\/\.\.\/\.\.\/build%' $file
58 sed -i -e 's%\.\.\/\.\.\/\libs%\.\.\/\.\.\/\.\.\/libs%' $file
61 # run the top-level test file through jscoverage
62 $CHROME_BIN --allow-file-access-from-files file://$DIR/instrumented/jscoverage.html?index.html