Merge: Rope api
authorJean Privat <jean@pryen.org>
Wed, 25 Jun 2014 22:07:11 +0000 (18:07 -0400)
committerJean Privat <jean@pryen.org>
Wed, 25 Jun 2014 22:07:11 +0000 (18:07 -0400)
Small modifications of the API that will be required for future pull requests such as Splay ropes and Bufferized ropes.

Pull-Request: #518
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Reviewed-by: Jean Privat <jean@pryen.org>

131 files changed:
.mailmap
benchmarks/bench_common.sh [new file with mode: 0644]
benchmarks/bench_engines.sh
benchmarks/bench_languages.sh
c_src/Makefile
src/Makefile
src/abstract_compiler.nit
src/debugger.nit
src/debugger_socket.nit [new file with mode: 0644]
src/global_compiler.nit
src/mkcsrc
src/nit.nit
tests/base_covar_int2.nit
tests/base_inline.nit
tests/base_inline_nested.nit
tests/base_output_class_name.nit
tests/base_var_null2.nit
tests/bench_tak.nit
tests/emscripten.skip [new file with mode: 0644]
tests/emscripten_nodejs.nit [new file with mode: 0644]
tests/nitg-e.skip
tests/nitg-g.skip
tests/nitg-s.skip
tests/nitg-sg.skip [new file with mode: 0644]
tests/niti.skip
tests/rterror_attr_def.nit
tests/sav/base_covar_int2.res
tests/sav/base_output_class_name.res
tests/sav/base_var_null2.res
tests/sav/base_var_null2_1alt3.res
tests/sav/base_var_null2_1alt3_alt2.res
tests/sav/base_var_null2_alt1.res
tests/sav/base_var_null2_alt2.res
tests/sav/bench_tak.res
tests/sav/emscripten/emscripten_nodejs.res [new file with mode: 0644]
tests/sav/emscripten/fixme/base_attr_gen_alt1.res [new file with mode: 0644]
tests/sav/emscripten/fixme/base_conflict_submodule_name.res [new file with mode: 0644]
tests/sav/emscripten/fixme/base_conflict_submodule_name_alt1.res [new file with mode: 0644]
tests/sav/emscripten/fixme/base_conflict_submodule_name_alt2.res [new file with mode: 0644]
tests/sav/emscripten_nodejs.res [new file with mode: 0644]
tests/sav/fixme/base_inline.res [new file with mode: 0644]
tests/sav/fixme/base_inline_nested.res [new file with mode: 0644]
tests/sav/fixme/base_inline_nested2.res [new file with mode: 0644]
tests/sav/fixme/zzz_test_fixme.res [new file with mode: 0644]
tests/sav/fixme/zzz_test_fixme_changed.res [new file with mode: 0644]
tests/sav/fixme/zzz_test_fixme_remains.res [new file with mode: 0644]
tests/sav/mnit.res [new file with mode: 0644]
tests/sav/nitg-e/base_output_class_name.res
tests/sav/nitg-e/fixme/base_covar_int2_alt1.res
tests/sav/nitg-e/fixme/base_covar_int2_alt3.res
tests/sav/nitg-e/fixme/base_covar_int2_alt5.res
tests/sav/nitg-e/fixme/converter.res [new file with mode: 0644]
tests/sav/nitg-e/fixme/pnacl.res [new file with mode: 0644]
tests/sav/nitg-g/fixme/base_covar_int2_alt3.res
tests/sav/nitg-g/fixme/base_covar_int2_alt5.res
tests/sav/nitg-g/fixme/pnacl.res [new file with mode: 0644]
tests/sav/nitg-s/fixme/base_attr_gen_alt1.res
tests/sav/nitg-s/fixme/base_covar_int2_alt1.res
tests/sav/nitg-s/fixme/base_covar_int2_alt3.res
tests/sav/nitg-s/fixme/base_covar_int2_alt5.res
tests/sav/nitg-s/fixme/converter.res [new file with mode: 0644]
tests/sav/nitg-s/fixme/pnacl.res [new file with mode: 0644]
tests/sav/nitg-sg/fixme/base_attr_gen_alt1.res [new file with mode: 0644]
tests/sav/nitg-sg/fixme/base_attr_init_val_raf_alt1.res [new file with mode: 0644]
tests/sav/nitg-sg/fixme/base_attr_nullable_int_alt1.res [new file with mode: 0644]
tests/sav/nitg-sg/fixme/base_attr_nullable_int_alt2.res [new file with mode: 0644]
tests/sav/nitg-sg/fixme/base_attr_nullable_int_alt3.res [new file with mode: 0644]
tests/sav/nitg-sg/fixme/base_attr_nullable_int_alt4.res [new file with mode: 0644]
tests/sav/nitg-sg/fixme/base_attr_nullable_int_alt5.res [new file with mode: 0644]
tests/sav/nitg-sg/fixme/base_conflict_submodule_name.res [moved from tests/sav/nitg-g/fixme/mnit.res with 100% similarity]
tests/sav/nitg-sg/fixme/base_conflict_submodule_name_alt1.res [new file with mode: 0644]
tests/sav/nitg-sg/fixme/base_conflict_submodule_name_alt2.res [new file with mode: 0644]
tests/sav/nitg-sg/fixme/base_covar_int2_alt1.res [new file with mode: 0644]
tests/sav/nitg-sg/fixme/base_covar_int2_alt3.res [new file with mode: 0644]
tests/sav/nitg-sg/fixme/base_covar_int2_alt5.res [new file with mode: 0644]
tests/sav/nitg-sg/fixme/base_covar_int_alt1.res [new file with mode: 0644]
tests/sav/nitg-sg/fixme/base_covar_int_alt3.res [new file with mode: 0644]
tests/sav/nitg-sg/fixme/base_covar_int_alt5.res [new file with mode: 0644]
tests/sav/nitg-sg/fixme/base_gen_infinite.res [new file with mode: 0644]
tests/sav/nitg-sg/fixme/base_gen_variance3_alt1.res [new file with mode: 0644]
tests/sav/nitg-sg/fixme/base_gen_variance_int_alt1.res [new file with mode: 0644]
tests/sav/nitg-sg/fixme/base_virtual_int2_alt2.res [new file with mode: 0644]
tests/sav/nitg-sg/fixme/base_virtual_type_variance_int_alt1.res [new file with mode: 0644]
tests/sav/nitg-sg/fixme/pnacl.res [new file with mode: 0644]
tests/sav/nitg-sg/fixme/test_gen.res [new file with mode: 0644]
tests/sav/niti/rterror_attr_def_alt7.res
tests/sav/rterror_attr_def.res
tests/sav/rterror_attr_def_alt7.res
tests/sav/rterror_attr_def_alt8.res
tests/sav/shootout_mandelbrot_args1.res
tests/sav/test_accessor.res [deleted file]
tests/sav/test_array.res [deleted file]
tests/sav/test_array_int.res [deleted file]
tests/sav/test_attr.res [deleted file]
tests/sav/test_attr_long.res [deleted file]
tests/sav/test_blocks.res [deleted file]
tests/sav/test_cond.res [deleted file]
tests/sav/test_gets.res
tests/sav/test_meta.res [deleted file]
tests/sav/test_obj.res [deleted file]
tests/sav/test_operator_brackets.res
tests/sav/test_string.res [deleted file]
tests/sav/zzz_test_fail.res [new file with mode: 0644]
tests/sav/zzz_test_fixme_changed.res [new file with mode: 0644]
tests/sav/zzz_test_fixme_remains.res [new file with mode: 0644]
tests/sav/zzz_test_ok.res [new file with mode: 0644]
tests/sav/zzz_test_soso.res [new file with mode: 0644]
tests/shootout_mandelbrot.nit
tests/test_accessor.nit [deleted file]
tests/test_array.nit [deleted file]
tests/test_array_int.nit [deleted file]
tests/test_attr.nit [deleted file]
tests/test_attr_long.nit [deleted file]
tests/test_blocks.nit [deleted file]
tests/test_cond.nit [deleted file]
tests/test_gets.nit
tests/test_meta.nit [deleted file]
tests/test_obj.nit [deleted file]
tests/test_operator_brackets.nit
tests/test_string.nit [deleted file]
tests/testall.sh
tests/tests.sh
tests/zzz_tests/zzz_test_0k.nit [new file with mode: 0644]
tests/zzz_tests/zzz_test_fail.nit [new file with mode: 0644]
tests/zzz_tests/zzz_test_fixme.nit [new file with mode: 0644]
tests/zzz_tests/zzz_test_fixme_changed.nit [new file with mode: 0644]
tests/zzz_tests/zzz_test_fixme_remains.nit [new file with mode: 0644]
tests/zzz_tests/zzz_test_nosav.nit [new file with mode: 0644]
tests/zzz_tests/zzz_test_ok.nit [new file with mode: 0644]
tests/zzz_tests/zzz_test_soso.nit [new file with mode: 0644]
tests/zzz_tests/zzz_test_todo.nit [new file with mode: 0644]

index a3e389c..695a4ce 100644 (file)
--- a/.mailmap
+++ b/.mailmap
@@ -23,3 +23,5 @@ Romain Chanoir <romain.chanoir@viacesi.fr>
 Clement de Figueiredo <clement.defigueiredo@gmail.com>
 
 Christophe Gigax <christophe.gigax@viacesi.fr>
+
+Julien Pagès <julien.projet@gmail.com>
diff --git a/benchmarks/bench_common.sh b/benchmarks/bench_common.sh
new file mode 100644 (file)
index 0000000..c600732
--- /dev/null
@@ -0,0 +1,87 @@
+#!/bin/bash
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Common functions for all the bench scripts
+
+# Run a single command multiple time and store the execution times
+# in the current $res file.
+#
+#  $1: title of the command
+#  $2: long desription of the command
+#  rest: the command to execute
+function bench_command()
+{
+       if [ "$dry_run" = "true" ]; then return; fi
+       local title="$1"
+       local desc="$2"
+       shift
+       shift
+       if test "$verbose" = true; then outputopts="/dev/stdout"; else outputopts="/dev/null"; fi
+       timeout="time.out"
+       echo "$title" > "$timeout"
+       echo "# $desc" >> "$timeout"
+       echo "\$ $@" >> "$timeout"
+       echo
+       echo "** [$title] $desc **"
+       echo " $ $@"
+
+       # Execute the commands $count times
+       for i in `seq 1 "$count"`; do
+               /usr/bin/time -f "%U" -o "$timeout" -a "$@" > $outputopts 2>&1 || die "$1: failed"
+               echo -n "$i. "
+               tail -n 1 "$timeout"
+       done
+
+       line=`compute_stats "$timeout"`
+       echo "$line ($res)"
+       echo $line >> "$res"
+}
+
+# Run a simble command witout storing the execution time
+# Used to display command on verbose and skip long executions when dry_run is given
+# $@ command to execute
+function run_command()
+{
+       if [ "$dry_run" = "true" ]; then return; fi
+       echo " $ $@"
+       "$@" || die "$@: failed"
+}
+
+# Check if the test should be skiped according to its name
+# $1: name of the test
+# $2: description of the test
+# $NOTSKIPED: arguments
+function skip_test()
+{
+       if test -z "$NOTSKIPED"; then
+               echo "* $1"
+               return 0
+       fi
+       if test "$NOTSKIPED" = "all"; then
+               : # Execute anyway
+       elif echo "$1" | egrep "$NOTSKIPED" >/dev/null 2>&1; then
+               : # Found one to execute
+       else
+               return 0
+       fi
+       if test -n "$html"; then
+               echo >>"$html" "<h2>$1</h2>"
+       fi
+       echo "*"
+       echo "* $1 *****"
+       echo "*"
+       return 1
+}
+
index 55db63e..abc65e3 100755 (executable)
@@ -17,6 +17,7 @@
 
 # TODO: cleanup and libify the helper-parts
 
+source ./bench_common.sh
 source ./bench_plot.sh
 
 ## CONFIGURATION OPTIONS ##
@@ -35,76 +36,6 @@ function die()
        died=1
 }
 
-# Run a single command multiple time and store the execution times
-# in the current $res file.
-#
-#  $1: title of the command
-#  $2: long desription of the command
-#  rest: the command to execute
-function bench_command()
-{
-       if [ "$dry_run" = "true" ]; then return; fi
-       local title="$1"
-       local desc="$2"
-       shift
-       shift
-       if test "$verbose" = true; then outputopts="/dev/stdout"; else outputopts="/dev/null"; fi
-       timeout="time.out"
-       echo "$title" > "$timeout"
-       echo "# $desc" >> "$timeout"
-       echo "\$ $@" >> "$timeout"
-       echo
-       echo "** [$title] $desc **"
-       echo " $ $@"
-
-       # Execute the commands $count times
-       for i in `seq 1 "$count"`; do
-               /usr/bin/time -f "%U" -o "$timeout" -a "$@" > $outputopts 2>&1 || die "$1: failed"
-               echo -n "$i. "
-               tail -n 1 "$timeout"
-       done
-
-       line=`compute_stats "$timeout"`
-       echo "$line ($res)"
-       echo $line >> "$res"
-}
-
-# Run a simble command witout storing the execution time
-# Used to display command on verbose and skip long executions when dry_run is given
-# $@ command to execute
-function run_command()
-{
-       if [ "$dry_run" = "true" ]; then return; fi
-       echo " $ $@"
-       "$@" || die "$@: failed"
-}
-
-# Check if the test should be skiped according to its name
-# $1: name of the test
-# $2: description of the test
-# $NOTSKIPED: arguments
-function skip_test()
-{
-       if test -z "$NOTSKIPED"; then
-               echo "* $1"
-               return 0
-       fi
-       if test "$NOTSKIPED" = "all"; then
-               : # Execute anyway
-       elif echo "$1" | egrep "$NOTSKIPED" >/dev/null 2>&1; then
-               : # Found one to execute
-       else
-               return 0
-       fi
-       if test -n "$html"; then
-               echo >>"$html" "<h2>$1</h2>"
-       fi
-       echo "*"
-       echo "* $1 *****"
-       echo "*"
-       return 1
-}
-
 # HELPER FOR NIT #
 
 # Run standards benchs on a compiler command
index d9db525..fea39ff 100755 (executable)
@@ -17,6 +17,7 @@
 
 # TODO: cleanup and libify the helper-parts
 
+source ./bench_common.sh
 source ./bench_plot.sh
 
 ## CONFIGURATION OPTIONS ##
@@ -33,74 +34,6 @@ function die()
        died=1
 }
 
-# Run a single command multiple time and store the execution times
-# in the current $res file.
-#
-#  $1: title of the command
-#  $2: long desription of the command
-#  rest: the command to execute
-function bench_command()
-{
-       if [ "$dry_run" = "true" ]; then return; fi
-       local title="$1"
-       local desc="$2"
-       shift
-       shift
-       if test "$verbose" = true; then outputopts="/dev/stdout"; else outputopts="/dev/null"; fi
-       timeout="time.out"
-       echo "$title" > "$timeout"
-       echo "# $desc" >> "$timeout"
-       echo "\$ $@" >> "$timeout"
-       echo
-       echo "** [$title] $desc **"
-       echo " $ $@"
-
-       # Execute the commands $count times
-       for i in `seq 1 "$count"`; do
-               (ulimit -t 300; /usr/bin/time -f "%U" -o "$timeout" -a "$@") > $outputopts 2>&1 || die "$1: failed"
-               echo -n "$i. "
-               tail -n 1 "$timeout"
-       done
-
-       line=`compute_stats "$timeout"`
-       echo "$line ($res)"
-       echo $line >> "$res"
-       rm $timeout
-}
-
-# Run a simple command witout storing the execution time
-# Used to display command on verbose and skip long executions when dry_run is given
-# $@ command to execute
-function run_command()
-{
-       if [ "$dry_run" = "true" ]; then return; fi
-       echo " $ $@"
-       (ulimit -t 180; "$@") || die "$@: failed"
-}
-
-# Check if the test should be skiped according to its name
-# $1: name of the test
-# $2: description of the test
-# $NOTSKIPED: arguments
-function skip_test()
-{
-       if test -z "$NOTSKIPED"; then
-               echo "* $1"
-               return 0
-       fi
-       if test "$NOTSKIPED" = "all"; then
-               : # Execute anyway
-       elif echo "$1" | egrep "$NOTSKIPED" >/dev/null 2>&1; then
-               : # Found one to execute
-       else
-               return 0
-       fi
-       echo "*"
-       echo "* $1 *****"
-       echo "*"
-       return 1
-}
-
 ## HANDLE OPTIONS ##
 
 function usage()
index 1453943..d94866c 100644 (file)
@@ -1,8 +1,22 @@
 CC = ccache cc
-CFLAGS = -g -O2
+CFLAGS = -g -O2 -Wno-unused-value -Wno-switch
 CINCL =  -I "clib"
 LDFLAGS ?= 
-LDLIBS  ?= -lm -lgc  -lunwind
+LDLIBS  ?= -lm -lgc
+
+NEED_LIBUNWIND := YesPlease
+uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
+ifeq ($(uname_S),Darwin)
+       NEED_LIBUNWIND :=
+endif
+
+clang_check := $(shell sh -c '$(CC) -v 2>&1 | grep -q clang; echo $$?')
+ifeq ($(clang_check), 0)
+       CFLAGS += -Qunused-arguments
+endif
+ifdef NEED_LIBUNWIND
+       LDLIBS += -lunwind
+endif
 
 all: nitg
 
index 211287d..2ca0fb7 100644 (file)
@@ -15,6 +15,7 @@
 # limitations under the License.
 
 NITCOPT=
+OLDNITCOPT= --no-stacktrace
 
 all: ../bin/nitdoc ../bin/nitmetrics ../bin/nitg ../bin/nit ../bin/nitx ../bin/nitunit ../bin/nitlight ../bin/nitls ../bin/nitdbg_client
 
@@ -23,7 +24,7 @@ nitg_0: ../c_src/nitg parser/parser.nit
        @echo '* Compile nitg_0 from NIT source files                          *'
        @echo '***************************************************************'
        ./git-gen-version.sh
-       ../c_src/nitg ${NITCOPT} -o nitg_0 -v nitg.nit
+       ../c_src/nitg ${OLDNITCOPT} -o nitg_0 -v nitg.nit
 
 ../bin/nitg: nitg_0 parser/parser.nit
        @echo '***************************************************************'
index 99b84be..e8d0179 100644 (file)
@@ -320,10 +320,28 @@ class MakefileToolchain
                        if libs != null then linker_options.add_all(libs)
                end
 
+               makefile.write("CC = ccache cc\nCFLAGS = -g -O2 -Wno-unused-value -Wno-switch\nCINCL = {cc_includes}\nLDFLAGS ?= \nLDLIBS  ?= -lm -lgc {linker_options.join(" ")}\n\n")
+
                var ost = toolcontext.opt_stacktrace.value
-               if ost == "libunwind" or ost == "nitstack" then linker_options.add("-lunwind")
+               if ost == "libunwind" or ost == "nitstack" then makefile.write("NEED_LIBUNWIND := YesPlease\n")
+
+               # Dynamic adaptations
+               # While `platform` enable complex toolchains, they are statically applied
+               # For a dynamic adaptsation of the compilation, the generated Makefile should check and adapt things itself
+
+               # Check and adapt the targeted system
+               makefile.write("uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')\n")
+               makefile.write("ifeq ($(uname_S),Darwin)\n")
+               # remove -lunwind since it is already included on macosx
+               makefile.write("\tNEED_LIBUNWIND :=\n")
+               makefile.write("endif\n\n")
+
+               # Check and adapt for the compiler used
+               # clang need an additionnal `-Qunused-arguments`
+               makefile.write("clang_check := $(shell sh -c '$(CC) -v 2>&1 | grep -q clang; echo $$?')\nifeq ($(clang_check), 0)\n\tCFLAGS += -Qunused-arguments\nendif\n")
+
+               makefile.write("ifdef NEED_LIBUNWIND\n\tLDLIBS += -lunwind\nendif\n")
 
-               makefile.write("CC = ccache cc\nCFLAGS = -g -O2\nCINCL = {cc_includes}\nLDFLAGS ?= \nLDLIBS  ?= -lm -lgc {linker_options.join(" ")}\n\n")
                makefile.write("all: {outpath}\n\n")
 
                var ofiles = new Array[String]
index 697f86b..75486cb 100644 (file)
@@ -23,7 +23,6 @@ import nitx
 intrude import local_var_init
 intrude import scope
 intrude import toolcontext
-import websocket
 
 redef class Model
        # Cleans the model to remove a module and what it defines when semantic analysis fails on injected code
@@ -124,23 +123,11 @@ redef class ToolContext
        # -c
        var opt_debugger_autorun: OptionBool = new OptionBool("Launches the target program with the interpreter, such as when the program fails, the debugging prompt is summoned", "-c")
 
-       # --socket
-       var opt_socket_mode = new OptionBool("Launches the target program with raw output on the network via sockets", "--socket")
-
-       # --websocket
-       var opt_websocket_mode = new OptionBool("Launches the target program with output on the network via websockets", "--websocket")
-
-       # --port
-       var opt_debug_port: OptionInt = new OptionInt("Sets the debug port (Defaults to 22125) - Must be contained between 0 and 65535", 22125, "--port")
-
        redef init
        do
                super
                self.option_context.add_option(self.opt_debugger_mode)
                self.option_context.add_option(self.opt_debugger_autorun)
-               self.option_context.add_option(self.opt_socket_mode)
-               self.option_context.add_option(self.opt_websocket_mode)
-               self.option_context.add_option(self.opt_debug_port)
        end
 end
 
@@ -158,12 +145,8 @@ redef class ModelBuilder
 
                var interpreter = new Debugger(self, mainmodule, arguments)
 
-               set_stdstreams
-
                init_naive_interpreter(interpreter, mainmodule)
 
-               close_stdstreams
-
                var time1 = get_time
                self.toolcontext.info("*** END INTERPRETING: {time1-time0} ***", 2)
        end
@@ -176,53 +159,11 @@ redef class ModelBuilder
                var interpreter = new Debugger(self, mainmodule, arguments)
                interpreter.autocontinue = true
 
-               set_stdstreams
-
                init_naive_interpreter(interpreter, mainmodule)
 
-               close_stdstreams
-
                var time1 = get_time
                self.toolcontext.info("*** END INTERPRETING: {time1-time0} ***", 2)
        end
-
-       redef fun run_naive_interpreter(mmod, args)
-       do
-               set_stdstreams
-               super
-       end
-
-       fun set_stdstreams
-       do
-               if self.toolcontext.opt_socket_mode.value then
-                       var sock = new Socket.server(toolcontext.opt_debug_port.value, 1)
-                       var ns = sock.accept
-                       sock.close
-                       sys.set_io(ns,ns,ns)
-               else if self.toolcontext.opt_websocket_mode.value then
-                       var websock = new WebSocket(toolcontext.opt_debug_port.value, 1)
-                       websock.accept
-                       sys.set_io(websock,websock,websock)
-               end
-       end
-
-       fun close_stdstreams
-       do
-               if sys.stdin isa WebSocket or sys.stdin isa Socket then
-                       sys.stdin.close
-                       sys.stdout.close
-                       sys.stderr.close
-               end
-       end
-end
-
-redef class Sys
-       private fun set_io(istream: PollableIStream, ostream: OStream, errstream: OStream)
-       do
-               self.stdin = istream
-               self.stdout = ostream
-               self.stderr = ostream
-       end
 end
 
 # The class extending `NaiveInterpreter` by adding debugging methods
diff --git a/src/debugger_socket.nit b/src/debugger_socket.nit
new file mode 100644 (file)
index 0000000..07cf16d
--- /dev/null
@@ -0,0 +1,121 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Copyright 2014 Johan Kayser <kayser.johan@gmail.com>
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Debugging of a nit program using sockets.
+module debugger_socket
+
+intrude import debugger
+import websocket
+
+redef class ToolContext
+       # --socket
+       var opt_socket_mode = new OptionBool("Launches the target program with raw output on the network via sockets", "--socket")
+
+       # --websocket
+       var opt_websocket_mode = new OptionBool("Launches the target program with output on the network via websockets", "--websocket")
+
+       # --port
+       var opt_debug_port: OptionInt = new OptionInt("Sets the debug port (Defaults to 22125) - Must be contained between 0 and 65535", 22125, "--port")
+
+       redef init
+       do
+               super
+               self.option_context.add_option(self.opt_socket_mode)
+               self.option_context.add_option(self.opt_websocket_mode)
+               self.option_context.add_option(self.opt_debug_port)
+       end
+end
+
+redef class ModelBuilder
+       # Execute the program from the entry point (Sys::main) of the `mainmodule`
+       # `arguments` are the command-line arguments in order
+       # REQUIRE that:
+       #   1. the AST is fully loaded.
+       #   2. the model is fully built.
+       #   3. the instructions are fully analysed.
+       redef fun run_debugger(mainmodule: MModule, arguments: Array[String])
+       do
+               var time0 = get_time
+               self.toolcontext.info("*** START INTERPRETING ***", 1)
+
+               var interpreter = new Debugger(self, mainmodule, arguments)
+
+               set_stdstreams
+
+               init_naive_interpreter(interpreter, mainmodule)
+
+               close_stdstreams
+
+               var time1 = get_time
+               self.toolcontext.info("*** END INTERPRETING: {time1-time0} ***", 2)
+       end
+
+       redef fun run_debugger_autorun(mainmodule: MModule, arguments: Array[String])
+       do
+               var time0 = get_time
+               self.toolcontext.info("*** START INTERPRETING ***", 1)
+
+               var interpreter = new Debugger(self, mainmodule, arguments)
+               interpreter.autocontinue = true
+
+               set_stdstreams
+
+               init_naive_interpreter(interpreter, mainmodule)
+
+               close_stdstreams
+
+               var time1 = get_time
+               self.toolcontext.info("*** END INTERPRETING: {time1-time0} ***", 2)
+       end
+
+       redef fun run_naive_interpreter(mmod, args)
+       do
+               set_stdstreams
+               super
+       end
+
+       fun set_stdstreams
+       do
+               if self.toolcontext.opt_socket_mode.value then
+                       var sock = new Socket.server(toolcontext.opt_debug_port.value, 1)
+                       var ns = sock.accept
+                       sock.close
+                       sys.set_io(ns,ns,ns)
+               else if self.toolcontext.opt_websocket_mode.value then
+                       var websock = new WebSocket(toolcontext.opt_debug_port.value, 1)
+                       websock.accept
+                       sys.set_io(websock,websock,websock)
+               end
+       end
+
+       fun close_stdstreams
+       do
+               if sys.stdin isa WebSocket or sys.stdin isa Socket then
+                       sys.stdin.close
+                       sys.stdout.close
+                       sys.stderr.close
+               end
+       end
+end
+
+redef class Sys
+       private fun set_io(istream: PollableIStream, ostream: OStream, errstream: OStream)
+       do
+               self.stdin = istream
+               self.stdout = ostream
+               self.stderr = ostream
+       end
+end
index 8c6ac6c..9e79281 100644 (file)
@@ -124,8 +124,8 @@ class GlobalCompiler
        # Compile class names (for the class_name and output_class_name methods)
        protected fun compile_class_names do
                var v = new_visitor
-               self.header.add_decl("extern const char const * class_names[];")
-               v.add("const char const * class_names[] = \{")
+               self.header.add_decl("extern const char *class_names[];")
+               v.add("const char *class_names[] = \{")
                for t in self.runtime_type_analysis.live_types do
                        v.add("\"{t}\", /* {self.classid(t)} */")
                end
index a408697..7ba4466 100755 (executable)
@@ -21,3 +21,6 @@ done
 perl -i -npe 's#"\.\./.*?([^/]*.h)"#"\1"#' "$out"/*.[ch]
 perl -i -npe 's#\S*/([^/]*.[ch])#\1#' "$out/Makefile"
 perl -i -npe 's#\.\./clib#.#' "$out/Makefile"
+
+# Remove old compilation flags
+sed -i -e 's/OLDNITCOPT=.*/OLDNITCOPT=/' src/Makefile
index 36c3815..dc48db8 100644 (file)
@@ -19,6 +19,7 @@ module nit
 
 import naive_interpreter
 import debugger
+import debugger_socket
 
 # Create a tool context to handle options and paths
 var toolcontext = new ToolContext
index 550f651..cb8bdc9 100644 (file)
@@ -44,3 +44,4 @@ d1.foo(d2).output
 #alt4#1.foo(c2).output
 #alt5#d1.foo(c2).output
 c1.foo(c2).output
+'\n'.output
index e684f95..1f31600 100644 (file)
@@ -18,7 +18,7 @@ import kernel
 
 interface Inline__
        fun foo do 1.output
-       fun bar: Int = 2
+       fun bar: Int do return 2
 end
 
 class A
index 44867dd..90d344a 100644 (file)
@@ -18,7 +18,7 @@ import kernel
 
 interface Inline__
        fun foo do bar.output
-       fun bar: Int = 2
+       fun bar: Int do return 2
        fun baz is abstract
 end
 
index 4776e65..f5fae31 100644 (file)
@@ -34,3 +34,4 @@ test1.output_class_name
 test2.output_class_name
 test3.output_class_name
 test4.output_class_name
+'\n'.output
index 084a19a..1b41bcc 100644 (file)
@@ -21,6 +21,7 @@ do
        if i == 2 then a = 2
        #1alt3#if i == 3 then a = '3'
        if a == null then 0.output else a.output
+       '\n'.output
 end
 
 test(1)
index 3ffaaf1..d5be5e8 100644 (file)
@@ -27,4 +27,4 @@ do
        end
 end
 
-printn(tak(37,12,6))
+print(tak(37,12,6))
diff --git a/tests/emscripten.skip b/tests/emscripten.skip
new file mode 100644 (file)
index 0000000..c782ec0
--- /dev/null
@@ -0,0 +1,2 @@
+init_inherit
+init_linext
diff --git a/tests/emscripten_nodejs.nit b/tests/emscripten_nodejs.nit
new file mode 100644 (file)
index 0000000..5ada70d
--- /dev/null
@@ -0,0 +1,13 @@
+import emscripten
+redef class IFStream
+       redef fun fill_buffer
+       do
+               print "NOT YET IMPLEMENTED"
+               abort
+       end
+       redef init open(f)
+       do
+               print "NOT YET IMPLEMENTED"
+               abort
+       end
+end
index 6aac93a..c782ec0 100644 (file)
@@ -1,6 +1,2 @@
 init_inherit
 init_linext
-inline
-test_json
-converter
-pnacl
index c626285..fb091a0 100644 (file)
@@ -1,6 +1,3 @@
 init_inherit
 init_linext
-inline
 nitg
-mnit
-pnacl
index 6aac93a..c782ec0 100644 (file)
@@ -1,6 +1,2 @@
 init_inherit
 init_linext
-inline
-test_json
-converter
-pnacl
diff --git a/tests/nitg-sg.skip b/tests/nitg-sg.skip
new file mode 100644 (file)
index 0000000..c782ec0
--- /dev/null
@@ -0,0 +1,2 @@
+init_inherit
+init_linext
index 7c2762c..afed2b6 100644 (file)
@@ -1,6 +1,5 @@
 init_inherit
 init_linext
-inline
 test_mem
 shoot_logic
 bench_
index 203f759..744ff2b 100644 (file)
@@ -45,6 +45,7 @@ class B
        fun foo
        do
                self.o.output
+               '\n'.output
                self.a.output
                self.b.output
                #alt2#self.c.output
@@ -57,3 +58,4 @@ end
 
 var b = new B
 b.foo
+'\n'.output
index 33afcf3..f916ec6 100644 (file)
@@ -1,4 +1,4 @@
 1
 1
 1
-a
\ No newline at end of file
+a
index cd2b594..611cfdb 100644 (file)
@@ -3,4 +3,4 @@ Int
 Test
 Test
 MyArray[Int]
-0
\ No newline at end of file
+0
index 5f5fbe7..7e7bac6 100644 (file)
@@ -1,3 +1,5 @@
 1
+
 2
-3
\ No newline at end of file
+
+3
index 3cacc0b..48082f7 100644 (file)
@@ -1 +1 @@
-12
\ No newline at end of file
+12
diff --git a/tests/sav/emscripten/emscripten_nodejs.res b/tests/sav/emscripten/emscripten_nodejs.res
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/tests/sav/emscripten/fixme/base_attr_gen_alt1.res b/tests/sav/emscripten/fixme/base_attr_gen_alt1.res
new file mode 100644 (file)
index 0000000..b4de394
--- /dev/null
@@ -0,0 +1 @@
+11
diff --git a/tests/sav/emscripten/fixme/base_conflict_submodule_name.res b/tests/sav/emscripten/fixme/base_conflict_submodule_name.res
new file mode 100644 (file)
index 0000000..4ad3dc3
--- /dev/null
@@ -0,0 +1 @@
+UNDEFINED
diff --git a/tests/sav/emscripten/fixme/base_conflict_submodule_name_alt1.res b/tests/sav/emscripten/fixme/base_conflict_submodule_name_alt1.res
new file mode 100644 (file)
index 0000000..4ad3dc3
--- /dev/null
@@ -0,0 +1 @@
+UNDEFINED
diff --git a/tests/sav/emscripten/fixme/base_conflict_submodule_name_alt2.res b/tests/sav/emscripten/fixme/base_conflict_submodule_name_alt2.res
new file mode 100644 (file)
index 0000000..4ad3dc3
--- /dev/null
@@ -0,0 +1 @@
+UNDEFINED
diff --git a/tests/sav/emscripten_nodejs.res b/tests/sav/emscripten_nodejs.res
new file mode 100644 (file)
index 0000000..174d681
--- /dev/null
@@ -0,0 +1 @@
+Not executable (platform?)
diff --git a/tests/sav/fixme/base_inline.res b/tests/sav/fixme/base_inline.res
new file mode 100644 (file)
index 0000000..336a4ce
--- /dev/null
@@ -0,0 +1,3 @@
+100
+200
+300
diff --git a/tests/sav/fixme/base_inline_nested.res b/tests/sav/fixme/base_inline_nested.res
new file mode 100644 (file)
index 0000000..9f4aea0
--- /dev/null
@@ -0,0 +1,3 @@
+20
+20
+20
diff --git a/tests/sav/fixme/base_inline_nested2.res b/tests/sav/fixme/base_inline_nested2.res
new file mode 100644 (file)
index 0000000..88a2829
--- /dev/null
@@ -0,0 +1,22 @@
+A10
+B9
+A8
+B7
+A6
+B5
+A4
+B3
+A2
+B1
+A0
+B10
+A9
+B8
+A7
+B6
+A5
+B4
+A3
+B2
+A1
+B0
diff --git a/tests/sav/fixme/zzz_test_fixme.res b/tests/sav/fixme/zzz_test_fixme.res
new file mode 100644 (file)
index 0000000..d00491f
--- /dev/null
@@ -0,0 +1 @@
+1
diff --git a/tests/sav/fixme/zzz_test_fixme_changed.res b/tests/sav/fixme/zzz_test_fixme_changed.res
new file mode 100644 (file)
index 0000000..573541a
--- /dev/null
@@ -0,0 +1 @@
+0
diff --git a/tests/sav/fixme/zzz_test_fixme_remains.res b/tests/sav/fixme/zzz_test_fixme_remains.res
new file mode 100644 (file)
index 0000000..d00491f
--- /dev/null
@@ -0,0 +1 @@
+1
diff --git a/tests/sav/mnit.res b/tests/sav/mnit.res
new file mode 100644 (file)
index 0000000..3b9e4fd
--- /dev/null
@@ -0,0 +1 @@
+Runtime error: Abstract method `generate_input` called on `App` (../lib/mnit/mnit_app.nit:64)
diff --git a/tests/sav/nitg-e/fixme/converter.res b/tests/sav/nitg-e/fixme/converter.res
new file mode 100644 (file)
index 0000000..4ad3dc3
--- /dev/null
@@ -0,0 +1 @@
+UNDEFINED
diff --git a/tests/sav/nitg-e/fixme/pnacl.res b/tests/sav/nitg-e/fixme/pnacl.res
new file mode 100644 (file)
index 0000000..4ad3dc3
--- /dev/null
@@ -0,0 +1 @@
+UNDEFINED
diff --git a/tests/sav/nitg-g/fixme/pnacl.res b/tests/sav/nitg-g/fixme/pnacl.res
new file mode 100644 (file)
index 0000000..4ad3dc3
--- /dev/null
@@ -0,0 +1 @@
+UNDEFINED
diff --git a/tests/sav/nitg-s/fixme/converter.res b/tests/sav/nitg-s/fixme/converter.res
new file mode 100644 (file)
index 0000000..4ad3dc3
--- /dev/null
@@ -0,0 +1 @@
+UNDEFINED
diff --git a/tests/sav/nitg-s/fixme/pnacl.res b/tests/sav/nitg-s/fixme/pnacl.res
new file mode 100644 (file)
index 0000000..4ad3dc3
--- /dev/null
@@ -0,0 +1 @@
+UNDEFINED
diff --git a/tests/sav/nitg-sg/fixme/base_attr_gen_alt1.res b/tests/sav/nitg-sg/fixme/base_attr_gen_alt1.res
new file mode 100644 (file)
index 0000000..4ad3dc3
--- /dev/null
@@ -0,0 +1 @@
+UNDEFINED
diff --git a/tests/sav/nitg-sg/fixme/base_attr_init_val_raf_alt1.res b/tests/sav/nitg-sg/fixme/base_attr_init_val_raf_alt1.res
new file mode 100644 (file)
index 0000000..2f1465d
--- /dev/null
@@ -0,0 +1,3 @@
+1
+1
+0
diff --git a/tests/sav/nitg-sg/fixme/base_attr_nullable_int_alt1.res b/tests/sav/nitg-sg/fixme/base_attr_nullable_int_alt1.res
new file mode 100644 (file)
index 0000000..5625f1f
--- /dev/null
@@ -0,0 +1,7 @@
+0
+0
+1
+2
+10
+20
+30
diff --git a/tests/sav/nitg-sg/fixme/base_attr_nullable_int_alt2.res b/tests/sav/nitg-sg/fixme/base_attr_nullable_int_alt2.res
new file mode 100644 (file)
index 0000000..2e8046c
--- /dev/null
@@ -0,0 +1,7 @@
+1
+0
+1
+2
+10
+20
+30
diff --git a/tests/sav/nitg-sg/fixme/base_attr_nullable_int_alt3.res b/tests/sav/nitg-sg/fixme/base_attr_nullable_int_alt3.res
new file mode 100644 (file)
index 0000000..f0c5f8f
--- /dev/null
@@ -0,0 +1,8 @@
+0
+0
+0
+1
+2
+10
+20
+30
diff --git a/tests/sav/nitg-sg/fixme/base_attr_nullable_int_alt4.res b/tests/sav/nitg-sg/fixme/base_attr_nullable_int_alt4.res
new file mode 100644 (file)
index 0000000..a12c8e0
--- /dev/null
@@ -0,0 +1,7 @@
+10
+0
+1
+2
+10
+20
+30
diff --git a/tests/sav/nitg-sg/fixme/base_attr_nullable_int_alt5.res b/tests/sav/nitg-sg/fixme/base_attr_nullable_int_alt5.res
new file mode 100644 (file)
index 0000000..f343f0e
--- /dev/null
@@ -0,0 +1,8 @@
+10
+20
+0
+1
+2
+10
+20
+30
diff --git a/tests/sav/nitg-sg/fixme/base_conflict_submodule_name_alt1.res b/tests/sav/nitg-sg/fixme/base_conflict_submodule_name_alt1.res
new file mode 100644 (file)
index 0000000..7f85acf
--- /dev/null
@@ -0,0 +1 @@
+Compilation error
diff --git a/tests/sav/nitg-sg/fixme/base_conflict_submodule_name_alt2.res b/tests/sav/nitg-sg/fixme/base_conflict_submodule_name_alt2.res
new file mode 100644 (file)
index 0000000..7f85acf
--- /dev/null
@@ -0,0 +1 @@
+Compilation error
diff --git a/tests/sav/nitg-sg/fixme/base_covar_int2_alt1.res b/tests/sav/nitg-sg/fixme/base_covar_int2_alt1.res
new file mode 100644 (file)
index 0000000..9c5d958
--- /dev/null
@@ -0,0 +1,4 @@
+1
+1
+a1
+a
diff --git a/tests/sav/nitg-sg/fixme/base_covar_int2_alt3.res b/tests/sav/nitg-sg/fixme/base_covar_int2_alt3.res
new file mode 100644 (file)
index 0000000..fbffc32
--- /dev/null
@@ -0,0 +1,4 @@
+1
+1
+1
+aa
diff --git a/tests/sav/nitg-sg/fixme/base_covar_int2_alt5.res b/tests/sav/nitg-sg/fixme/base_covar_int2_alt5.res
new file mode 100644 (file)
index 0000000..5f6d34c
--- /dev/null
@@ -0,0 +1,5 @@
+1
+1
+1
+1
+a
diff --git a/tests/sav/nitg-sg/fixme/base_covar_int_alt1.res b/tests/sav/nitg-sg/fixme/base_covar_int_alt1.res
new file mode 100644 (file)
index 0000000..f98f9e1
--- /dev/null
@@ -0,0 +1,5 @@
+true
+true
+false
+true
+true
diff --git a/tests/sav/nitg-sg/fixme/base_covar_int_alt3.res b/tests/sav/nitg-sg/fixme/base_covar_int_alt3.res
new file mode 100644 (file)
index 0000000..d3413ee
--- /dev/null
@@ -0,0 +1,5 @@
+true
+true
+true
+false
+true
diff --git a/tests/sav/nitg-sg/fixme/base_covar_int_alt5.res b/tests/sav/nitg-sg/fixme/base_covar_int_alt5.res
new file mode 100644 (file)
index 0000000..36c7afa
--- /dev/null
@@ -0,0 +1,5 @@
+true
+true
+true
+true
+true
diff --git a/tests/sav/nitg-sg/fixme/base_gen_infinite.res b/tests/sav/nitg-sg/fixme/base_gen_infinite.res
new file mode 100644 (file)
index 0000000..4fff55f
--- /dev/null
@@ -0,0 +1 @@
+Fatal error: limitation in the rapidtype analysis engine: a type depth of 256 is too important, the problematic type is G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[G[Int]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]].
diff --git a/tests/sav/nitg-sg/fixme/base_gen_variance3_alt1.res b/tests/sav/nitg-sg/fixme/base_gen_variance3_alt1.res
new file mode 100644 (file)
index 0000000..0096ae2
--- /dev/null
@@ -0,0 +1,4 @@
+2
+2
+!2
+!100
diff --git a/tests/sav/nitg-sg/fixme/base_gen_variance_int_alt1.res b/tests/sav/nitg-sg/fixme/base_gen_variance_int_alt1.res
new file mode 100644 (file)
index 0000000..3ab4fdc
--- /dev/null
@@ -0,0 +1,2 @@
+Cast error: Cannot cast Char to Int.
+2
diff --git a/tests/sav/nitg-sg/fixme/base_virtual_int2_alt2.res b/tests/sav/nitg-sg/fixme/base_virtual_int2_alt2.res
new file mode 100644 (file)
index 0000000..2e435a2
--- /dev/null
@@ -0,0 +1,3 @@
+4
+4
+4
diff --git a/tests/sav/nitg-sg/fixme/base_virtual_type_variance_int_alt1.res b/tests/sav/nitg-sg/fixme/base_virtual_type_variance_int_alt1.res
new file mode 100644 (file)
index 0000000..3ab4fdc
--- /dev/null
@@ -0,0 +1,2 @@
+Cast error: Cannot cast Char to Int.
+2
diff --git a/tests/sav/nitg-sg/fixme/pnacl.res b/tests/sav/nitg-sg/fixme/pnacl.res
new file mode 100644 (file)
index 0000000..4ad3dc3
--- /dev/null
@@ -0,0 +1 @@
+UNDEFINED
diff --git a/tests/sav/nitg-sg/fixme/test_gen.res b/tests/sav/nitg-sg/fixme/test_gen.res
new file mode 100644 (file)
index 0000000..4ad3dc3
--- /dev/null
@@ -0,0 +1 @@
+UNDEFINED
index 4c87b06..4d56903 100644 (file)
@@ -1,2 +1,2 @@
-Runtime error: Uninitialized attribute @a (alt/rterror_attr_def_alt7.nit:48)
-c
\ No newline at end of file
+Runtime error: Uninitialized attribute @a (alt/rterror_attr_def_alt7.nit:49)
+c
index c4a680e..4c1d495 100644 (file)
@@ -1,2 +1,2 @@
 Runtime error: Uninitialized attribute @a (alt/rterror_attr_def_alt7.nit:24)
-c
\ No newline at end of file
+c
index 66ef874..53f24b9 100644 (file)
@@ -1,2 +1,3 @@
-Runtime error: Receiver is null (alt/rterror_attr_def_alt8.nit:49)
-c1
+Runtime error: Receiver is null (alt/rterror_attr_def_alt8.nit:50)
+c
+1
index 2c6ff6b..505c003 100644 (file)
Binary files a/tests/sav/shootout_mandelbrot_args1.res and b/tests/sav/shootout_mandelbrot_args1.res differ
diff --git a/tests/sav/test_accessor.res b/tests/sav/test_accessor.res
deleted file mode 100644 (file)
index ea889b9..0000000
+++ /dev/null
@@ -1 +0,0 @@
-p: 5q: 67
\ No newline at end of file
diff --git a/tests/sav/test_array.res b/tests/sav/test_array.res
deleted file mode 100644 (file)
index 2bfea71..0000000
+++ /dev/null
@@ -1 +0,0 @@
-2**0*1*
\ No newline at end of file
diff --git a/tests/sav/test_array_int.res b/tests/sav/test_array_int.res
deleted file mode 100644 (file)
index 1a4284d..0000000
+++ /dev/null
@@ -1 +0,0 @@
-2530513
\ No newline at end of file
diff --git a/tests/sav/test_attr.res b/tests/sav/test_attr.res
deleted file mode 100644 (file)
index 8dfe4ff..0000000
+++ /dev/null
@@ -1 +0,0 @@
-55125012
\ No newline at end of file
diff --git a/tests/sav/test_attr_long.res b/tests/sav/test_attr_long.res
deleted file mode 100644 (file)
index efb4310..0000000
+++ /dev/null
@@ -1 +0,0 @@
-0010110010
\ No newline at end of file
diff --git a/tests/sav/test_blocks.res b/tests/sav/test_blocks.res
deleted file mode 100644 (file)
index f54df58..0000000
+++ /dev/null
@@ -1 +0,0 @@
-012345
\ No newline at end of file
diff --git a/tests/sav/test_cond.res b/tests/sav/test_cond.res
deleted file mode 100644 (file)
index 56b6510..0000000
+++ /dev/null
@@ -1 +0,0 @@
-11111
\ No newline at end of file
index 5d25dd1..a3f0a73 100644 (file)
@@ -1 +1,2 @@
-bonjourndjui
\ No newline at end of file
+bonjour
+ndjui
diff --git a/tests/sav/test_meta.res b/tests/sav/test_meta.res
deleted file mode 100644 (file)
index 67b0910..0000000
+++ /dev/null
@@ -1 +0,0 @@
-D34=578
\ No newline at end of file
diff --git a/tests/sav/test_obj.res b/tests/sav/test_obj.res
deleted file mode 100644 (file)
index 6527f27..0000000
+++ /dev/null
@@ -1 +0,0 @@
-11211221122132
\ No newline at end of file
index 42b5dfa..bb61552 100644 (file)
@@ -1 +1,3 @@
-112155
\ No newline at end of file
+11
+21
+55
diff --git a/tests/sav/test_string.res b/tests/sav/test_string.res
deleted file mode 100644 (file)
index 5769d17..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-abcdefghijklnmopqrstuvwxyz
-#"\
\ No newline at end of file
diff --git a/tests/sav/zzz_test_fail.res b/tests/sav/zzz_test_fail.res
new file mode 100644 (file)
index 0000000..573541a
--- /dev/null
@@ -0,0 +1 @@
+0
diff --git a/tests/sav/zzz_test_fixme_changed.res b/tests/sav/zzz_test_fixme_changed.res
new file mode 100644 (file)
index 0000000..83b33d2
--- /dev/null
@@ -0,0 +1 @@
+1000
diff --git a/tests/sav/zzz_test_fixme_remains.res b/tests/sav/zzz_test_fixme_remains.res
new file mode 100644 (file)
index 0000000..d00491f
--- /dev/null
@@ -0,0 +1 @@
+1
diff --git a/tests/sav/zzz_test_ok.res b/tests/sav/zzz_test_ok.res
new file mode 100644 (file)
index 0000000..d00491f
--- /dev/null
@@ -0,0 +1 @@
+1
diff --git a/tests/sav/zzz_test_soso.res b/tests/sav/zzz_test_soso.res
new file mode 100644 (file)
index 0000000..41aa675
--- /dev/null
@@ -0,0 +1,3 @@
+Error: other error
+Warning: some warning
+0
index fb6b5dd..f8482b2 100644 (file)
@@ -25,7 +25,7 @@ var iter = 20
 var limit = 2.0
 
 if args.length != 1 then
-    printn("Usage: shootout_mandelbrot <size>\n")
+    print("Usage: shootout_mandelbrot <size>")
     return
 end
 
@@ -35,7 +35,7 @@ var h = w
 var byte_acc = 0
 var bit_num = 0
 
-printn("P4\n{w} {h}\n")
+print("P4\n{w} {h}")
 
 for y in [0..h[ do
     for x in [0..w[ do
@@ -73,3 +73,4 @@ for y in [0..h[ do
        end
     end
 end
+print ""
diff --git a/tests/test_accessor.nit b/tests/test_accessor.nit
deleted file mode 100644 (file)
index e83de63..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-# This file is part of NIT ( http://www.nitlanguage.org ).
-#
-# Copyright 2004-2008 Jean Privat <jean@pryen.org>
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-class A
-   fun p=(i: Int)
-   do
-      printn("p: ", i)
-   end
-   fun q=(i: Int, j: Int)
-   do
-      printn("q: ", i, j)
-   end
-
-   init
-   do
-   end
-end
-
-var a = new A
-a.p = 5
-a.q(6) = 7
diff --git a/tests/test_array.nit b/tests/test_array.nit
deleted file mode 100644 (file)
index fcce3bb..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-# This file is part of NIT ( http://www.nitlanguage.org ).
-#
-# Copyright 2004-2008 Jean Privat <jean@pryen.org>
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-
-class Ant
-       redef fun to_s: String
-       do
-               return "*"
-       end
-
-       init do end
-end
-
-var t = [new Ant, new Ant]
-printn(t.length)
-printn(t)
-var i = 0
-while i < t.length do
-       printn(i)
-       printn(t[i])
-       i = i + 1
-end
diff --git a/tests/test_array_int.nit b/tests/test_array_int.nit
deleted file mode 100644 (file)
index 0719bbb..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-# This file is part of NIT ( http://www.nitlanguage.org ).
-#
-# Copyright 2004-2008 Jean Privat <jean@pryen.org>
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-
-      var t = [5,3]
-         printn(t.length)
-         printn(t)
-         var i = 0
-         while i < t.length do
-            printn(i)
-            printn(t[i])
-            i = i + 1
-         end
diff --git a/tests/test_attr.nit b/tests/test_attr.nit
deleted file mode 100644 (file)
index d667658..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-# This file is part of NIT ( http://www.nitlanguage.org ).
-#
-# Copyright 2004-2008 Jean Privat <jean@pryen.org>
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-redef class Sys
-       var _i: Int = 0
-       var _j: Int = 0
-       redef fun main
-       do
-               printn(5)
-               _i = 5
-               printn(_i)
-               _i = 12
-               printn(_i)
-               _j = 50
-               printn(_j)
-               printn(_i)
-       end
-end
diff --git a/tests/test_attr_long.nit b/tests/test_attr_long.nit
deleted file mode 100644 (file)
index 1444e23..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-# This file is part of NIT ( http://www.nitlanguage.org ).
-#
-# Copyright 2004-2008 Jean Privat <jean@pryen.org>
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-class A
-       var _a_: Int = 0
-
-       fun a: Int
-       do
-               return _a_ * 10
-       end
-
-       fun a=(a: Int)
-       do
-               _a_ = a / 10
-       end
-
-
-
-       init
-       do
-       end
-end
-
-
-var a = new A
-printn(a.a, a._a_)
-a.a = 10
-printn(a.a, a._a_)
-a._a_ = 10
-printn(a.a, a._a_)
diff --git a/tests/test_blocks.nit b/tests/test_blocks.nit
deleted file mode 100644 (file)
index ce22835..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-# This file is part of NIT ( http://www.nitlanguage.org ).
-#
-# Copyright 2004-2008 Jean Privat <jean@pryen.org>
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-
-         do
-           printn(0)
-        end
-         var a = 1
-        do
-           printn(a)
-        end
-        var b = 2
-        while b < 3 do
-           printn(b)
-           b = b + 1
-        end
-        var c = 3
-        while c < 4 do
-           printn(c)
-           c = c + 1
-        end
-        var d = 4 
-        var e = 2
-        while e > 0 do
-           printn(d)
-           d = d + 1 
-           e = e - 1
-        end
diff --git a/tests/test_cond.nit b/tests/test_cond.nit
deleted file mode 100644 (file)
index 3246b45..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-# This file is part of NIT ( http://www.nitlanguage.org ).
-#
-# Copyright 2004-2008 Jean Privat <jean@pryen.org>
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-var a = true
-var b = false
-
-if true then
-       printn(1)
-else if false then
-       printn(0)
-else if true then
-       printn(0)
-else
-       printn(0)
-end
-
-if false then
-       printn(0)
-else if false then
-       printn(0)
-else if true then
-       printn(1)
-else
-       printn(0)
-end 
-
-if false then
-       printn(0)
-else if false then
-       printn(0)
-else
-       printn(1)
-end
-
-if a then
-       printn(1)
-else
-       printn(0)
-end
-
-if b then
-       printn(0)
-else
-       printn(1)
-end
index a7efb38..ad1112a 100644 (file)
@@ -14,5 +14,5 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-printn(gets)
-printn(gets)
+print(gets)
+print(gets)
diff --git a/tests/test_meta.nit b/tests/test_meta.nit
deleted file mode 100644 (file)
index b649f99..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-# This file is part of NIT ( http://www.nitlanguage.org ).
-#
-# Copyright 2004-2008 Jean Privat <jean@pryen.org>
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-
-class A
-   fun foo
-      do
-          printn("A")
-      end
-   fun blup(a: Int)
-      do
-         blup2(a, 1)
-      end
-   fun blup2(a: Int, b : Int)
-      do
-         printn(a+b)
-      end
-   fun blop(a: Int, b: Int...)
-      do
-         var i = b.iterator
-         while i.is_ok do
-            printn(a+i.item)
-            i.next
-         end
-      end
-end
-
-class B
-       super A
-   redef fun foo
-      do
-          printn("B")
-      end
-end
-
-class C
-       super A
-   fun foo2
-      do
-          printn("C")
-      end
-end
-
-class D
-       super B
-       super C
-   redef fun foo
-      do
-          printn("D")
-      end
-
-   init do end
-end
-
-fun test1
-do
-       var b: B
-       b = new D
-       b.foo
-       b.blup2(1,2)
-       b.blup(3)
-end
-
-fun test2
-do
-       var b = new D
-       var a = [1,2,3]
-       var u: Object
-       printn("=",5)
-       b.blop(5,2,3)
-end
-
-test1
-test2
diff --git a/tests/test_obj.nit b/tests/test_obj.nit
deleted file mode 100644 (file)
index f4a430b..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-# This file is part of NIT ( http://www.nitlanguage.org ).
-#
-# Copyright 2004-2008 Jean Privat <jean@pryen.org>
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-
-class O
-   fun foo
-   do
-      printn(10)
-   end
-   
-   fun bar
-   do
-      printn(20)
-   end
-
-   init do end
-end
-
-class A
-       super O
-   redef fun foo
-   do
-      printn(11)
-   end
-   
-   redef fun bar
-   do
-      printn(21)
-   end
-
-   init do end
-end
-
-class B
-       super A
-   redef fun foo
-   do
-      printn(12)
-   end
-   
-   fun baz
-   do
-      printn(32)
-   end
-
-   init do end
-end
-
-var a = new A
-var ab: A = new B
-var b = new B
-a.foo
-a.bar
-ab.foo
-ab.bar
-b.foo
-b.bar
-b.baz
index 2f680d4..cbf28d8 100644 (file)
@@ -66,6 +66,6 @@ var m = new Matrice
 m[1,1] = 11
 m[2,1] = 21
 m[5,5] = 55
-printn(m[1,1])
-printn(m[2,1])
-printn(m[5,5])
+print(m[1,1])
+print(m[2,1])
+print(m[5,5])
diff --git a/tests/test_string.nit b/tests/test_string.nit
deleted file mode 100644 (file)
index c76b0b3..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-# This file is part of NIT ( http://www.nitlanguage.org ).
-#
-# Copyright 2004-2008 Jean Privat <jean@pryen.org>
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-
-printn("abcdefghijklnmopqrstuvwxyz")
-printn("\n#\"\\")
index c053160..8176ab2 100755 (executable)
@@ -1,4 +1,4 @@
-for x in nitg-g nitg-s nitg-e niti; do
+for x in nitg-g nitg-s nitg-sg nitg-e niti; do
        echo "--engine $x"
        ./tests.sh --engine $x "$@"
 done
index 956c0ab..6cfb9be 100755 (executable)
@@ -19,6 +19,7 @@
 
 # Set lang do default to avoid failed tests because of locale
 export LANG=C
+export LC_ALL=C
 export NIT_TESTING=true
 
 unset NIT_DIR
@@ -42,10 +43,8 @@ Usage: $e [options] modulenames
 -o option   Pass option to the engine
 -v          Verbose (show tests steps)
 -h          This help
---tap       Produce TAP output
 --engine    Use a specific engine (default=nitg)
 --noskip    Do not skip a test even if the .skip file matches
---[no]soso  Force enable (or disable) SOSO
 END
 }
 
@@ -61,16 +60,16 @@ function compare_to_result()
        local pattern="$1"
        local sav="$2"
        if [ ! -r "$sav" ]; then return 0; fi
+       test "`cat "$sav"`" = "UNDEFINED" && return 1
        diff -u "$sav" "out/$pattern.res" > "out/$pattern.diff.sav.log"
        if [ "$?" == 0 ]; then
                return 1
        fi
-       [ -z "$soso" ] && return 3
        sed '/[Ww]arning/d;/[Ee]rror/d' "out/$pattern.res" > "out/$pattern.res2"
        sed '/[Ww]arning/d;/[Ee]rror/d' "$sav" > "out/$pattern.sav2"
        grep '[Ee]rror' "out/$pattern.res" >/dev/null && echo "Error" >> "out/$pattern.res2"
        grep '[Ee]rror' "$sav" >/dev/null && echo "Error" >> "out/$pattern.sav2"
-       diff -u "out/$pattern.sav2" "out/$pattern.res2" > "out/$pattern.diff.sav.log"
+       diff -u "out/$pattern.sav2" "out/$pattern.res2" > "out/$pattern.diff.sav.log2"
        if [ "$?" == 0 ]; then
                return 2
        else
@@ -81,7 +80,6 @@ function compare_to_result()
 # As argument: the pattern used for the file
 function process_result()
 {
-       ((tapcount=tapcount+1))
        # Result
        pattern=$1
        description=$2
@@ -100,46 +98,63 @@ function process_result()
        echo >>$xml "<testcase classname='$pack' name='$description'>"
        #for sav in "sav/$engine/fixme/$pattern.res" "sav/$engine/$pattern.res" "sav/fixme/$pattern.res" "sav/$pattern.res" "sav/$pattern.sav"; do
        for savdir in $savdirs; do
-               sav=$savdir/$pattern.res
+               sav=$savdir/fixme/$pattern.res
                compare_to_result "$pattern" "$sav"
-
-               case "$? $sav" in
-                       0*)
-                               continue;; # no file
-                       1*/fixme/*)
+               case "$?" in
+                       0)
+                               ;; # no file
+                       1)
                                OLD="$LIST"
                                FIXME="$sav"
+                               LIST="$LIST $sav"
                                ;;
-                       1*)
+                       2)
+                               if [ -z "$FIRST" ]; then
+                                       SOSOF="$sav"
+                                       FIRST="$sav"
+                               fi
+                               LIST="$LIST $sav"
+                               ;;
+                       3)
+                               if [ -z "$FIRST" ]; then
+                                       NFIXME="$sav"
+                                       FIRST="$sav"
+                               fi
+                               LIST="$LIST $sav"
+                               ;;
+               esac
+
+               sav=$savdir/$pattern.res
+               compare_to_result "$pattern" "$sav"
+               case "$?" in
+                       0)
+                               ;; # no file
+                       1)
                                OLD="$LIST"
                                SAV="$sav"
+                               LIST="$LIST $sav"
                                ;;
-                       2*/fixme/*)
-                               SOSOF="$sav" ;;
-                       2*)
-                               SOSO="$sav" ;;
-                       3*/fixme/*)
+                       2)
                                if [ -z "$FIRST" ]; then
-                                       NFIXME="$sav"
+                                       SOSO="$sav"
                                        FIRST="$sav"
                                fi
+                               LIST="$LIST $sav"
                                ;;
-                       3*)
+                       3)
                                if [ -z "$FIRST" ]; then
                                        NSAV="$sav"
                                        FIRST="$sav"
                                fi
+                               LIST="$LIST $sav"
                                ;;
                esac
-               LIST="$LIST $sav"
        done
        OLD=`echo "$OLD" | sed -e 's/   */ /g' -e 's/^ //' -e 's/ $//'`
        grep 'NOT YET IMPLEMENTED' "out/$pattern.res" >/dev/null
        NYI="$?"
        if [ -n "$SAV" ]; then
-               if [ -n "$tap" ]; then
-                       echo "ok - $description"
-               elif [ -n "$OLD" ]; then
+               if [ -n "$OLD" ]; then
                        echo "[*ok*] out/$pattern.res $SAV - but $OLD remains!"
                        echo >>$xml "<error message='ok out/$pattern.res - but $OLD remains'/>"
                        remains="$remains $OLD"
@@ -148,9 +163,7 @@ function process_result()
                fi
                ok="$ok $pattern"
        elif [ -n "$FIXME" ]; then
-               if [ -n "$tap" ]; then
-                       echo "not ok - $description # TODO expected failure"
-               elif [ -n "$OLD" ]; then
+               if [ -n "$OLD" ]; then
                        echo "[*fixme*] out/$pattern.res $FIXME - but $OLD remains!"
                        echo >>$xml "<error message='ok out/$pattern.res - but $OLD remains'/>"
                        remains="$remains $OLD"
@@ -159,35 +172,28 @@ function process_result()
                        echo >>$xml "<skipped/>"
                fi
                todos="$todos $pattern"
-       elif [ -n "$SOSO" ]; then
-               if [ -n "$tap" ]; then
-                       echo "ok - $description # SOSO"
-               else
-                       echo "[soso] out/$pattern.res $SOSO"
-               fi
-               ok="$ok $pattern"
        elif [ "x$NYI" = "x0" ]; then
-               if [ -n "$tap" ]; then
-                       echo "not ok - $description # TODO not yet implemented"
-               else
-                       echo "[todo] out/$pattern.res -> not yet implemented"
-                       echo >>$xml "<skipped/>"
-               fi
+               echo "[todo] out/$pattern.res -> not yet implemented"
+               echo >>$xml "<skipped/>"
                todos="$todos $pattern"
+       elif [ -n "$SOSO" ]; then
+               echo "[======= soso out/$pattern.res $SOSO =======]"
+               echo >>$xml "<error message='soso out/$pattern.res $SOSO'/>"
+               echo >>$xml "<system-out><![CDATA["
+               cat -v out/$pattern.diff.sav.log | head >>$xml -n 50
+               echo >>$xml "]]></system-out>"
+               nok="$nok $pattern"
+               echo "$ii" >> "$ERRLIST"
        elif [ -n "$SOSOF" ]; then
-               if [ -n "$tap" ]; then
-                       echo "not ok - $description # TODO SOSO expected failure"
-               else
-                       echo "[fixme soso] out/$pattern.res $SOSOF"
-                       echo >>$xml "<skipped/>"
-               fi
-               todos="$todos $pattern"
+               echo "[======= fixme soso out/$pattern.res $SOSOF =======]"
+               echo >>$xml "<error message='soso out/$pattern.res $SOSO'/>"
+               echo >>$xml "<system-out><![CDATA["
+               cat -v out/$pattern.diff.sav.log | head >>$xml -n 50
+               echo >>$xml "]]></system-out>"
+               nok="$nok $pattern"
+               echo "$ii" >> "$ERRLIST"
        elif [ -n "$NSAV" ]; then
-               if [ -n "$tap" ]; then
-                       echo "not ok - $description"
-               else
-                       echo "[======= fail out/$pattern.res $NSAV =======]"
-               fi
+               echo "[======= fail out/$pattern.res $NSAV =======]"
                echo >>$xml "<error message='fail out/$pattern.res $NSAV'/>"
                echo >>$xml "<system-out><![CDATA["
                cat -v out/$pattern.diff.sav.log | head >>$xml -n 50
@@ -195,11 +201,7 @@ function process_result()
                nok="$nok $pattern"
                echo "$ii" >> "$ERRLIST"
        elif [ -n "$NFIXME" ]; then
-               if [ -n "$tap" ]; then
-                       echo "not ok - $description"
-               else
-                       echo "[======= changed out/$pattern.res $NFIXME ======]"
-               fi
+               echo "[======= changed out/$pattern.res $NFIXME ======]"
                echo >>$xml "<error message='changed out/$pattern.res $NFIXME'/>"
                echo >>$xml "<system-out><![CDATA["
                cat -v out/$pattern.diff.sav.log | head >>$xml -n 50
@@ -207,11 +209,7 @@ function process_result()
                nok="$nok $pattern"
                echo "$ii" >> "$ERRLIST"
        elif [ -s out/$pattern.res ]; then
-               if [ -n "$tap" ]; then
-                       echo "no ok - $description"
-               else
-                       echo "[=== no sav ===] out/$pattern.res is not empty"
-               fi
+               echo "[=== no sav ===] out/$pattern.res is not empty"
                echo >>$xml "<error message='no sav and not empty'/>"
                echo >>$xml "<system-out><![CDATA["
                cat -v >>$xml out/$pattern.res
@@ -219,11 +217,7 @@ function process_result()
                nos="$nos $pattern"
        else
                # no sav but empty res
-               if [ -n "$tap" ]; then
-                       echo "ok - $description"
-               else
-                       echo "[0k] out/$pattern.res is empty"
-               fi
+               echo "[0k] out/$pattern.res is empty"
                ok="$ok $pattern"
        fi
        if test -s out/$pattern.cmp.err; then
@@ -238,22 +232,12 @@ need_skip()
 {
        test "$noskip" = true && return 1
        if echo "$1" | grep -f "$engine.skip" >/dev/null 2>&1; then
-               ((tapcount=tapcount+1))
-               if [ -n "$tap" ]; then
-                       echo "ok - $2 # skip"
-               else
-                       echo "=> $2: [skip]"
-               fi
+               echo "=> $2: [skip]"
                echo >>$xml "<testcase classname='$3' name='$2'><skipped/></testcase>"
                return 0
        fi
        if test $engine = niti && echo "$1" | grep -f "exec.skip" >/dev/null 2>&1; then
-               ((tapcount=tapcount+1))
-               if [ -n "$tap" ]; then
-                       echo "ok - $2 # skip"
-               else
-                       echo "=> $2: [skip exec]"
-               fi
+               echo "=> $2: [skip exec]"
                echo >>$xml "<testcase classname='$3' name='$2'><skipped/></testcase>"
                return 0
        fi
@@ -281,41 +265,28 @@ skip_cc()
 
 find_nitc()
 {
-       ((tapcount=tapcount+1))
        name="$enginebinname"
        recent=`ls -t ../src/$name ../src/$name_[0-9] ../bin/$name ../c_src/$name 2>/dev/null | head -1`
        if [[ "x$recent" == "x" ]]; then
-               if [ -n "$tap" ]; then
-                       echo "not ok - find binary for $engine"
-                       echo "Bail out! Could not find binary for engine $engine, aborting"
-               else
-                       echo "Could not find binary for engine $engine, aborting"
-               fi
+               echo "Could not find binary for engine $engine, aborting"
                exit 1
        fi
-       if [ -n "$tap" ]; then
-               echo "ok - find binary for $engine: $recent $OPT"
-       else
-               echo "Find binary for engine $engine: $recent $OPT"
-       fi
+       echo "Find binary for engine $engine: $recent $OPT"
        NITC=$recent
 }
 
 verbose=false
 stop=false
-tapcount=0
 engine=nitg
 noskip=
+savdirs=
 while [ $stop = false ]; do
        case $1 in
                -o) OPT="$OPT $2"; shift; shift;;
                -v) verbose=true; shift;;
                -h) usage; exit;;
-               --tap) tap=true; shift;;
                --engine) engine="$2"; shift; shift;;
                --noskip) noskip=true; shift;;
-               --soso) soso=true; shift;;
-               --nososo) nososo=true; shift;;
                *) stop=true
        esac
 done
@@ -324,31 +295,34 @@ case $engine in
        nitg)
                engine=nitg-s;
                enginebinname=nitg;
-               savdirs="sav/$engine/fixme/ sav/$engine/ sav/fixme/ sav/"
                OPT="--separate $OPT"
                ;;
        nitg-s)
                enginebinname=nitg;
-               savdirs="sav/$engine/fixme/ sav/$engine/ sav/fixme/ sav/"
                OPT="--separate $OPT"
                ;;
        nitg-e)
                enginebinname=nitg;
-               savdirs="sav/$engine/fixme/ sav/$engine/ sav/fixme/ sav/"
                OPT="--erasure $OPT"
                ;;
+       nitg-sg)
+               enginebinname=nitg;
+               OPT="--semi-global $OPT"
+               ;;
        nitg-g)
                enginebinname=nitg;
-               savdirs="sav/$engine/fixme/ sav/$engine/ sav/fixme/ sav/"
                OPT="--global $OPT"
                ;;
        nit)
                engine=niti
-               savdirs="sav/$engine/fixme/ sav/$engine/ sav/fixme/ sav/"
                ;;
        niti)
                enginebinname=nit
-               savdirs="sav/$engine/fixme/ sav/$engine/ sav/fixme/ sav/"
+               ;;
+       emscripten)
+               enginebinname=nitg
+               OPT="-m emscripten_nodejs.nit --semi-global $OPT"
+               savdirs="sav/nitg-sg/"
                ;;
        nitc)
                echo "disabled engine $engine"
@@ -360,6 +334,8 @@ case $engine in
                ;;
 esac
 
+savdirs="sav/$engine $savdirs sav/"
+
 # The default nitc compiler
 [ -z "$NITC" ] && find_nitc
 
@@ -431,7 +407,7 @@ for ii in "$@"; do
                # Sould we skip the alternative for this engine?
                need_skip $bf $bf $pack && continue
 
-               test -z "$tap" && echo -n "=> $bf: "
+               echo -n "=> $bf: "
 
                if [ -f "$f.inputs" ]; then
                        inputs="$f.inputs"
@@ -439,6 +415,11 @@ for ii in "$@"; do
                        inputs=/dev/null
                fi
 
+               ffout="$ff.bin"
+               if [ "$engine" = "emscripten" ]; then
+                       ffout="$ff.bin.js"
+               fi
+
                if [ "$engine" = "niti" ]; then
                        cat > "./$ff.bin" <<END
 exec $NITC --no-color $OPT "$i" $includes -- "\$@"
@@ -456,18 +437,27 @@ END
                        # Compile
                        if [ "x$verbose" = "xtrue" ]; then
                                echo ""
-                               echo $NITC --no-color $OPT -o "$ff.bin" "$i" "$includes" $nocc
+                               echo $NITC --no-color $OPT -o "$ffout" "$i" "$includes" $nocc
                        fi
                        NIT_NO_STACK=1 JNI_LIB_PATH=$JNI_LIB_PATH JAVA_HOME=$JAVA_HOME \
-                               $TIMEOUT $NITC --no-color $OPT -o "$ff.bin" "$i" $includes $nocc 2> "$ff.cmp.err" > "$ff.compile.log"
+                               $TIMEOUT $NITC --no-color $OPT -o "$ffout" "$i" $includes $nocc 2> "$ff.cmp.err" > "$ff.compile.log"
                        ERR=$?
                        if [ "x$verbose" = "xtrue" ]; then
                                cat "$ff.compile.log"
                                cat >&2 "$ff.cmp.err"
                        fi
                fi
+               if [ "$engine" = "emscripten" ]; then
+                       echo > "./$ff.bin" "nodejs $ffout \"\$@\""
+                       chmod +x "$ff.bin"
+                       if grep "Fatal Error: more than one primitive class" "$ff.compile.log" > /dev/null; then
+                               echo " [skip] do no not imports kernel"
+                               echo >>$xml "<testcase classname='$pack' name='$bf'><skipped/></testcase>"
+                               continue
+                       fi
+               fi
                if [ "$ERR" != 0 ]; then
-                       test -z "$tap" && echo -n "! "
+                       echo -n "! "
                        cat "$ff.compile.log" "$ff.cmp.err" > "$ff.res"
                        process_result $bf $bf $pack
                elif skip_exec "$bf"; then
@@ -476,11 +466,11 @@ END
                        process_result $bf $bf $pack
                elif [ -n "$nocc" ]; then
                        # not compiled
-                       test -z "$tap" && echo -n "nocc "
+                       echo -n "nocc "
                        > "$ff.res"
                        process_result $bf $bf $pack
                elif [ -x "./$ff.bin" ]; then
-                       test -z "$tap" && echo -n ". "
+                       echo -n ". "
                        # Execute
                        args=""
                        if [ "x$verbose" = "xtrue" ]; then
@@ -527,7 +517,7 @@ END
                                                echo ""
                                                echo "NIT_NO_STACK=1 ./$ff.bin" $args
                                        fi
-                                       test -z "$tap" && echo -n "==> $name "
+                                       echo -n "==> $name "
                                        echo "./$ff.bin $args" > "./$fff.bin"
                                        chmod +x "./$fff.bin"
                                        WRITE="$fff.write" sh -c "NIT_NO_STACK=1 $TIMEOUT ./$fff.bin < $ffinputs > $fff.res 2>$fff.err"
@@ -551,7 +541,7 @@ END
                        echo "Not executable (platform?)" > "$ff.res"
                        process_result $bf "$bf" $pack
                else
-                       test -z "$tap" && echo -n "! "
+                       echo -n "! "
                        cat "$ff.cmp.err" > "$ff.res"
                        echo "Compilation error" > "$ff.res"
                        process_result $bf "$bf" $pack
@@ -559,16 +549,6 @@ END
        done
 done
 
-if [ -n "$tap" ]; then
-       echo "1..$tapcount"
-       echo "# ok:" `echo $ok | wc -w`
-       echo "# not ok:" `echo $nok | wc -w`
-       echo "# no sav:" `echo $nos | wc -w`
-       echo "# todo/fixme:" `echo $todos | wc -w`
-       echo "# of sav that remains:" `echo $remains | wc -w`
-       exit
-fi
-
 echo "engine: $engine ($enginebinname $OPT)"
 echo "ok: " `echo $ok | wc -w` "/" `echo $ok $nok $nos $todos | wc -w`
 
diff --git a/tests/zzz_tests/zzz_test_0k.nit b/tests/zzz_tests/zzz_test_0k.nit
new file mode 100644 (file)
index 0000000..8de86e9
--- /dev/null
@@ -0,0 +1 @@
+import kernel
diff --git a/tests/zzz_tests/zzz_test_fail.nit b/tests/zzz_tests/zzz_test_fail.nit
new file mode 100644 (file)
index 0000000..c76b503
--- /dev/null
@@ -0,0 +1,2 @@
+import kernel
+1.output
diff --git a/tests/zzz_tests/zzz_test_fixme.nit b/tests/zzz_tests/zzz_test_fixme.nit
new file mode 100644 (file)
index 0000000..c76b503
--- /dev/null
@@ -0,0 +1,2 @@
+import kernel
+1.output
diff --git a/tests/zzz_tests/zzz_test_fixme_changed.nit b/tests/zzz_tests/zzz_test_fixme_changed.nit
new file mode 100644 (file)
index 0000000..c76b503
--- /dev/null
@@ -0,0 +1,2 @@
+import kernel
+1.output
diff --git a/tests/zzz_tests/zzz_test_fixme_remains.nit b/tests/zzz_tests/zzz_test_fixme_remains.nit
new file mode 100644 (file)
index 0000000..c76b503
--- /dev/null
@@ -0,0 +1,2 @@
+import kernel
+1.output
diff --git a/tests/zzz_tests/zzz_test_nosav.nit b/tests/zzz_tests/zzz_test_nosav.nit
new file mode 100644 (file)
index 0000000..c76b503
--- /dev/null
@@ -0,0 +1,2 @@
+import kernel
+1.output
diff --git a/tests/zzz_tests/zzz_test_ok.nit b/tests/zzz_tests/zzz_test_ok.nit
new file mode 100644 (file)
index 0000000..c76b503
--- /dev/null
@@ -0,0 +1,2 @@
+import kernel
+1.output
diff --git a/tests/zzz_tests/zzz_test_soso.nit b/tests/zzz_tests/zzz_test_soso.nit
new file mode 100644 (file)
index 0000000..6106e56
--- /dev/null
@@ -0,0 +1,3 @@
+import string
+0.output
+"Error: bla bla".output
diff --git a/tests/zzz_tests/zzz_test_todo.nit b/tests/zzz_tests/zzz_test_todo.nit
new file mode 100644 (file)
index 0000000..d1c18f5
--- /dev/null
@@ -0,0 +1,2 @@
+import string
+"NOT YET IMPLEMENTED".output