Revert "Export"
[framework/web/web-ui-fw.git] / tests / coverage / instrument.sh
1 #!/bin/bash
2 # Run instrumented unit tests
3 #
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`)
8
9 # where are we?
10 SCRIPT_PATH=`readlink -f $0`
11
12 if [[ "x" == "x$SCRIPT_PATH" ]] ; then
13   DIR=`dirname $0`
14 else
15   DIR=`dirname $SCRIPT_PATH`
16 fi
17
18 # programs we need to run
19 if [[ "x" == "x$CHROME_BIN" ]] ; then
20   CHROME_BIN=`which google-chrome || which chromium-browser`
21 fi
22
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"
26   exit 1
27 fi
28
29 if [[ "x" == "x$JSCOVERAGE_BIN" ]] ; then
30   JSCOVERAGE_BIN=`which jscoverage`
31 fi
32
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"
36   exit 1
37 fi
38
39 # directory for instrumented files
40 if [ -d $DIR/instrumented ] ; then
41   rm -Rf $DIR/instrumented
42 fi
43
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
47
48 # copy all the unit tests to the instrumented directory
49 cp -a $DIR/../unit-tests/* $DIR/instrumented/
50
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
55
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
59 done
60
61 # run the top-level test file through jscoverage
62 $CHROME_BIN --allow-file-access-from-files file://$DIR/instrumented/jscoverage.html?index.html