From d9590f1611550f27a5ac66e9a8d32662ff1fb0dd Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Tue, 17 Jun 2014 15:48:11 +0200 Subject: [PATCH 1/2] Move forgotten file. --- tests/{desugar.sh => jsparser.sh} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tests/{desugar.sh => jsparser.sh} (100%) diff --git a/tests/desugar.sh b/tests/jsparser.sh similarity index 100% rename from tests/desugar.sh rename to tests/jsparser.sh From 9adce18ac35d9df3614f60d89510c9616bf2e954 Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Wed, 25 Jun 2014 10:27:12 +0200 Subject: [PATCH 2/2] Use paths relative to the current file, not to the current working directory. --- src/s5.ml | 2 +- tests/jsparser.sh | 4 +++- tests/s5 | 16 +++++++++------- tests/s5-desugar | 8 +++++--- tests/s5-test262 | 6 ++++-- tests/save_snapshots.sh | 16 +++++++++------- tests/single_test.sh | 8 ++++++-- 7 files changed, 37 insertions(+), 23 deletions(-) diff --git a/src/s5.ml b/src/s5.ml index b745f4b9..210e6efd 100644 --- a/src/s5.ml +++ b/src/s5.ml @@ -55,7 +55,7 @@ module S5 = struct (* Global Options *) - let jsparser_path = ref "../tests/jsparser.sh" + let jsparser_path = ref (Filename.concat (Filename.dirname Sys.executable_name) "../tests/jsparser.sh") let stack_trace = ref true let set_stack_trace (cmdName : string) (on : bool) : unit = diff --git a/tests/jsparser.sh b/tests/jsparser.sh index 8263b79a..a67fb5cd 100755 --- a/tests/jsparser.sh +++ b/tests/jsparser.sh @@ -1,4 +1,6 @@ #!/bin/bash -../bin/js -e "print(JSON.stringify(Reflect.parse(read('$1'),{loc:true}),function(key,value){if(key==='value'&&(value)instanceof(RegExp)){return{re_lit:String(value)}}return(value)},2))" +BASE_PATH=`dirname $0`/.. + +$BASE_PATH/bin/js -e "print(JSON.stringify(Reflect.parse(read('$1'),{loc:true}),function(key,value){if(key==='value'&&(value)instanceof(RegExp)){return{re_lit:String(value)}}return(value)},2))" exit $? diff --git a/tests/s5 b/tests/s5 index d0ff5404..662b5c5e 100755 --- a/tests/s5 +++ b/tests/s5 @@ -4,6 +4,8 @@ # e.g. s5 test.js -eval # e.g. s5 stdin -eval +BASE_PATH=`dirname $0`/.. + TMP=`mktemp -t js.XXXXXX` if [ $1 == "stdin" ]; then cat>$TMP @@ -12,15 +14,15 @@ else JSFILE=$1 fi -ocamlrun ../obj/s5.d.byte \ +ocamlrun $BASE_PATH/obj/s5.d.byte \ -desugar $JSFILE \ - -env ../envs/regexp.env -apply \ - -desugar ../lib/js-regexp/regexp.js -to-env -apply \ - -env ../envs/json.env -apply \ - -desugar ../lib/json/json_parse.js -to-env -apply \ - -desugar ../lib/json/json2.js -to-env -apply \ + -env $BASE_PATH/envs/regexp.env -apply \ + -desugar $BASE_PATH/lib/js-regexp/regexp.js -to-env -apply \ + -env $BASE_PATH/envs/json.env -apply \ + -desugar $BASE_PATH/lib/json/json_parse.js -to-env -apply \ + -desugar $BASE_PATH/lib/json/json2.js -to-env -apply \ -internal-env env-vars -apply \ - -env ../envs/es5.env -apply \ + -env $BASE_PATH/envs/es5.env -apply \ ${@:2} EX=$? diff --git a/tests/s5-desugar b/tests/s5-desugar index c05904e4..1e4bfac4 100755 --- a/tests/s5-desugar +++ b/tests/s5-desugar @@ -1,5 +1,7 @@ #!/bin/bash +BASE_PATH=`dirname $0`/.. + TMP=`mktemp -t js.XXXXXX` if [ $# -eq 0 ]; then cat>$TMP @@ -8,10 +10,10 @@ else fi RETMP=`mktemp -t js.XXXXXX` -../bin/js json_print.js ../lib/js-regexp/regexp.js > $RETMP +$BASE_PATH/bin/js $BASE_PATH/tests/json_print.js $BASE_PATH/lib/js-regexp/regexp.js > $RETMP -../bin/js json_print.js $TMP > $TMP.ast -ocamlrun ../obj/s5.d.byte -set-json ../tests/desugar.sh \ +$BASE_PATH/bin/js $BASE_PATH/tests/json_print.js $TMP > $TMP.ast +ocamlrun $BASE_PATH/obj/s5.d.byte -set-json $BASE_PATH/tests/desugar.sh \ -js $TMP.ast -js-to-s5 \ -print-src rm $RETMP diff --git a/tests/s5-test262 b/tests/s5-test262 index 52bc8f40..dcac3c6f 100755 --- a/tests/s5-test262 +++ b/tests/s5-test262 @@ -1,5 +1,7 @@ #!/bin/bash +BASE_PATH=`dirname $0`/.. + TMP=`mktemp -t js.XXXXXX` if [ $# -eq 0 ]; then cat>$TMP @@ -8,10 +10,10 @@ else JSFILE=$1 fi -ocamlrun ../obj/s5.d.byte \ +ocamlrun $BASE_PATH/obj/s5.d.byte \ -desugar $JSFILE \ -internal-env env-vars -apply \ - -env ../envs/es5.env -apply \ + -env $BASE_PATH/envs/es5.env -apply \ -eval-s5 EX=$? rm $TMP diff --git a/tests/save_snapshots.sh b/tests/save_snapshots.sh index e508be16..d861193d 100755 --- a/tests/save_snapshots.sh +++ b/tests/save_snapshots.sh @@ -4,16 +4,18 @@ # ses initialization. Save them in init.heap and ses.heap. # Regenerate the snapshots if (i) they don't exist, or (ii) they are out of date -if [ ! -f init.heap -o ../obj/s5.d.byte -nt init.heap \ - -o ! -f ses.heap -o ../obj/s5.d.byte -nt ses.heap \ - -o ! -f seseval.heap -o ../obj/s5.d.byte -nt seseval.heap ]; then +BASE_PATH=`dirname $0`/.. + +if [ ! -f init.heap -o $BASE_PATH/obj/s5.d.byte -nt init.heap \ + -o ! -f ses.heap -o $BASE_PATH/obj/s5.d.byte -nt ses.heap \ + -o ! -f seseval.heap -o $BASE_PATH/obj/s5.d.byte -nt seseval.heap ]; then echo "save_snapshots.sh: Rebuilding heap snapshots" -echo "___takeS5Snapshot()" | ./s5 stdin -eval-s5 -save init.heap +echo "___takeS5Snapshot()" | $BASE_PATH/tests/s5 stdin -eval-s5 -save init.heap -(cat ses/es-lab-tests/initSESPlus.js; echo "___takeS5Snapshot();") | ./s5 stdin -eval-s5 -save ses.heap +(cat $BASE_PATH/tests/ses/es-lab-tests/initSESPlus.js; echo "___takeS5Snapshot();") | $BASE_PATH/tests/s5 stdin -eval-s5 -save ses.heap -(cat ses/es-lab-tests/initSESPlus.js; echo "cajaVM.eval(\"___takeS5Snapshot();\");") | ./s5 stdin -eval-s5 -save seseval.heap +(cat $BASE_PATH/tests/ses/es-lab-tests/initSESPlus.js; echo "cajaVM.eval(\"___takeS5Snapshot();\");") | $BASE_PATH/tests/s5 stdin -eval-s5 -save seseval.heap -fi \ No newline at end of file +fi diff --git a/tests/single_test.sh b/tests/single_test.sh index 13e5d120..ea4ae212 100755 --- a/tests/single_test.sh +++ b/tests/single_test.sh @@ -1,5 +1,7 @@ #!/bin/bash +BASE_PATH=`dirname $0`/.. + if [ ! -f 'init.heap' ]; then echo "Rebuilding heap snapshots..." source save_snapshots.sh &> /dev/null @@ -13,19 +15,21 @@ if [ $# -gt 1 ]; then VERB='t' echo 'Running test file: '$2 fi - COMM='../obj/s5.d.byte -load init.heap -desugar '$2' -continue-'$TYPE'-eval' + COMM=$BASE_PATH'/obj/s5.d.byte -load init.heap -desugar '$2' -continue-'$TYPE'-eval' STR1=`$COMM` TEST=`echo $STR1 | grep "passed\|Passed"` if [ -n "$TEST" ]; then echo 'Passed' + RETURN_CODE=0 else echo 'Failed' + RETURN_CODE=1 fi if [ $VERB ]; then echo 'Test output:' echo $STR1 fi - exit 0 + exit $RETURN_CODE fi fi echo "Usage: single_test.sh {s5, cesk} some/file/path.js (-v)"