File tree Expand file tree Collapse file tree 1 file changed +8
-12
lines changed
Expand file tree Collapse file tree 1 file changed +8
-12
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,6 @@ JS_SLANG="node node_modules/js-slang/dist/repl/repl.js"
44
55SOURCEFILES=src/* /* .js
66SOURCE_TEST=" src/test/framework/main.js"
7- SOURCE_TEST_FILENAME=" source-test.js"
87
98red=` tput setaf 1`
109green=` tput setaf 2`
3332# $1 is the source file to be tested
3433# $2 is the Source test file which uses the source-test framework
3534test_source_framework () {
36- # run concatenation of source-test framework and test file
35+ # run concatenation of source-test framework, source and test files
3736 RESULTS=$( $JS_SLANG -e --chapter=4 " $( cat $SOURCE_TEST $1 $2 ) " )
3837
3938 # retrieve names for tests that passed
@@ -65,17 +64,14 @@ main() {
6564 # call test_source on each test case in __tests__
6665 for i in " $DIR /__tests__/$( basename ${s} .js) " .*
6766 do
68- test_source $s $i
69- done
70-
71- # check if source-test framework is being used
72- TEST_PATH=" $DIR /__tests__/$SOURCE_TEST_FILENAME "
73- if [ -e $TEST_PATH ]
74- then
75- test_source_framework $s $TEST_PATH
76- fi
67+ # check if first line of test file contains '// source-test'
68+ use_source_test=$( awk ' FNR==1{if ($0~"//[[:space:]]*source-test") print "yes";}' $i )
69+ if [[ $use_source_test == " yes" ]]
70+ then test_source_framework $s $i
71+ else test_source $s $i
72+ fi
73+ done
7774 fi
78-
7975 done
8076}
8177
You can’t perform that action at this time.
0 commit comments