The produced .js files are then executed by nodejs.
All base tests that do not import kernel are skipped because
since the module lib/emscripten.nit imports the kernel module,
an automatic double definition of classes `Object` and `Sys` occurs.
nodejs cannot perform correctly synchronized input, thus `stdin` and all
file reading does not work although they work in a browser.
As a workaround, a special module `emscripten_nodejs.nit` is added that just
print "NOT_YET_IMPLEMENTED" on unsupported services on synchronized input,
thus marking the test as skipped.
Currently, 99 (7% of the 1390 tests) still cause some other kind of failures;
they will be investigated later.
The whole testing of all the tests takes 68m on my machine.
ccache in unusable and the option --jcache of emcc does not bring any boost.
So it is unlikely that `testall.sh` will include this engine.
Signed-off-by: Jean Privat <jean@pryen.org>
--- /dev/null
+init_inherit
+init_linext
--- /dev/null
+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
--- /dev/null
+Not executable (platform?)
niti)
enginebinname=nit
;;
+ emscripten)
+ enginebinname=nitg
+ OPT="-m emscripten_nodejs.nit --semi-global $OPT"
+ savdirs="sav/nitg-sg/"
+ ;;
nitc)
echo "disabled engine $engine"
exit 0
fi
ffout="$ff.bin"
+ if [ "$engine" = "emscripten" ]; then
+ ffout="$ff.bin.js"
+ fi
if [ "$engine" = "niti" ]; then
cat > "./$ff.bin" <<END
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
echo -n "! "
cat "$ff.compile.log" "$ff.cmp.err" > "$ff.res"