Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relative path #41

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/s5.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
4 changes: 0 additions & 4 deletions tests/desugar.sh

This file was deleted.

6 changes: 6 additions & 0 deletions tests/jsparser.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

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 $?
16 changes: 9 additions & 7 deletions tests/s5
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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=$?
Expand Down
8 changes: 5 additions & 3 deletions tests/s5-desugar
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

BASE_PATH=`dirname $0`/..

TMP=`mktemp -t js.XXXXXX`
if [ $# -eq 0 ]; then
cat>$TMP
Expand All @@ -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
Expand Down
6 changes: 4 additions & 2 deletions tests/s5-test262
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

BASE_PATH=`dirname $0`/..

TMP=`mktemp -t js.XXXXXX`
if [ $# -eq 0 ]; then
cat>$TMP
Expand All @@ -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
Expand Down
16 changes: 9 additions & 7 deletions tests/save_snapshots.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
fi
8 changes: 6 additions & 2 deletions tests/single_test.sh
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)"
Expand Down