44# Author: Geoff Gustafson <[email protected] >55
66# trlite - a local version of the tests we run in Travis
7- # trlite [-j] [-nN] [-v] [vmname] [startnum] [endnum]
7+ # trlite [-l] [- j] [-nN] [-v] [vmname] [startnum] [endnum]
88#
9- # -nN appends N to .trlite directory name
9+ # (for now, options must appear in specified order)
10+ # -l runs tests in ZJS_BASE instead of a clean git clone
1011# -j runs all tests, with parallel execution (4 threads currently)
12+ # -nN appends N to .trlite directory name
1113# -v turns on verbose output
1214# by default, runs all tests
1315# trlite 1 or trlite zephyr runs just VM #1 "zephyr" tests
@@ -27,7 +29,15 @@ if [ ! -d "$ZJS_BASE" ]; then
2729 exit 1
2830fi
2931
30- TRLDIR=$ZJS_BASE /.trlite
32+ RUNLOCAL=n
33+
34+ if [ " $1 " == " -l" ]; then
35+ RUNLOCAL=y
36+ shift
37+ else
38+ TRLDIR=$ZJS_BASE /.trlite
39+ fi
40+
3141TMPFILE=/tmp/zjstest.js
3242
3343if [ " $1 " == " -h" -o " $1 " == " -?" ]; then
@@ -58,6 +68,11 @@ function display_errors() # NAME, NUM
5868}
5969
6070if [[ $1 == -j* ]]; then
71+ if [ " $RUNLOCAL " == " y" ]; then
72+ echo Error: -j mode cannot be used with -l
73+ exit 1
74+ fi
75+
6176 LOGFILE=/tmp/trlite-log
6277
6378 echo Running all trlite tests in four parallel threads...
@@ -86,6 +101,11 @@ if [[ $1 == -j* ]]; then
86101fi
87102
88103if [[ $1 == -n * ]]; then
104+ if [ " $RUNLOCAL " == " y" ]; then
105+ echo Error: -n mode cannot be used with -l
106+ exit 1
107+ fi
108+
89109 TRLDIR=$TRLDIR ${1: 2}
90110 TMPFILE=$TMPFILE ${1: 2}
91111 echo TRLDIR: $TRLDIR >> /tmp/foo
@@ -121,51 +141,56 @@ if [[ "$1" =~ ^[0-9]+$ ]]; then
121141 shift
122142fi
123143
124- rm -rf $TRLDIR
125-
126144echo Building ZJS tree: " $ZJS_BASE "
127- echo Cloning git tree...
128- git clone -l $ZJS_BASE $TRLDIR > /dev/null 2>&1
129-
130- # we need to refer to master later for diffs
131- cp $ZJS_BASE /.git/refs/heads/master $TRLDIR /.git/refs/heads
132-
133- echo Cloning git submodules...
134- cd $TRLDIR /deps
135- for i in * /; do
136- git clone -l ../../deps/$i /.git $i > /dev/null 2>&1
137-
138- # clone submodules of submodules
139- if [ -d $i /deps/ ]; then
140- cd $i /deps
141- for j in * /; do
142- git clone -l ../../../../deps/$i /deps/$j /.git $j > /dev/null 2>&1
143- done
144- cd ../..
145+
146+ if [ " $RUNLOCAL " != " y" ]; then
147+ rm -rf $TRLDIR
148+
149+ echo Cloning git tree...
150+ git clone -l $ZJS_BASE $TRLDIR > /dev/null 2>&1
151+
152+ # we need to refer to master later for diffs
153+ cp $ZJS_BASE /.git/refs/heads/master $TRLDIR /.git/refs/heads
154+
155+ echo Cloning git submodules...
156+ cd $TRLDIR /deps
157+ for i in * /; do
158+ git clone -l ../../deps/$i /.git $i > /dev/null 2>&1
159+
160+ # clone submodules of submodules
161+ if [ -d $i /deps/ ]; then
162+ cd $i /deps
163+ for j in * /; do
164+ git clone -l ../../../../deps/$i /deps/$j /.git $j > /dev/null 2>&1
165+ done
166+ cd ../..
167+ fi
168+ done
169+
170+ echo Preserving uncommitted changes:
171+ cd $ZJS_BASE
172+ git --no-pager diff HEAD --stat
173+ git diff HEAD > $TRLDIR /uncommitted.patch
174+ cd $TRLDIR
175+ patch -p1 < uncommitted.patch > /dev/null
176+
177+ # pause to allow consideration of diffs being applied
178+ if [ -z $TRAVIS ]; then
179+ sleep 3
145180 fi
146- done
147-
148- echo Preserving uncommitted changes:
149- cd $ZJS_BASE
150- git --no-pager diff HEAD --stat
151- git diff HEAD > $TRLDIR /uncommitted.patch
152- cd $TRLDIR
153- patch -p1 < uncommitted.patch > /dev/null
154-
155- # pause to allow consideration of diffs being applied
156- if [ -z $TRAVIS ]; then
157- sleep 3
158- fi
159181
160- echo Updating submodules...
161- make update
182+ echo Updating submodules...
183+ make update
184+
185+ source zjs-env.sh
186+ source deps/zephyr/zephyr-env.sh
187+ else
188+ cd $ZJS_BASE
189+ fi
162190
163191echo
164192echo Running tests...
165193
166- source zjs-env.sh
167- source deps/zephyr/zephyr-env.sh
168-
169194# requires: first arg is a <=10-char label, second arg is command
170195# effects: runs banner with label, then runs the command; if it fails, prints
171196# label before exiting
@@ -377,7 +402,9 @@ if [ "$RUN" == "all" -o "$RUN" == "4" ]; then
377402fi
378403
379404# clean up on success
380- cd $ZJS_BASE
381- rm -rf $TRLDIR
405+ if [ " $RUNLOCAL " != " y" ]; then
406+ cd $ZJS_BASE
407+ rm -rf $TRLDIR
408+ fi
382409exit 0
383410}
0 commit comments