Cannot build tests

1 view
Skip to first unread message

ben kuin

unread,
Dec 20, 2009, 10:55:32 AM12/20/09
to ocamljs...@googlegroups.com
hi

I try to build the tests:

    cd ocamljs-read-only
    ./configure -srcdir ~/install/ocamlsrc/ocaml-3.11.0
    make all
    make test

error:
    _build/main.js:294: ReferenceError: print_verbatim is not defined

context:

thats the line 294 in main.js:
    vim test/ocamljs/_build/main.js +294
   ~
   294 var caml_ml_output = function (c, b, s, l) { print_verbatim(b); }
   ~

and that's the corresponding line in ocaml:
    vim /usr/local/lib/ocaml/primitives.js +280
    ~
    280 var caml_ml_output = function (c, b, s, l) { print_verbatim(b); }
    ~

specs:
     ubuntu karmic (9.10)
     ocaml 3.11.0
     ocamljs Rev. 232

any ideas?
thanks
ben

log:
 1 make -C test
  2 make[1]: Entering directory `/var/userdata/it/lekuin.ben/com.github/git.lekuin.stuff/projects/ocamljs/ocamljs-read-only/test'
  3 for dir in jslib ocamljs stdlib; do \
  4         make -C $dir all || exit; \
  5     done
  6 make[2]: Entering directory `/var/userdata/it/lekuin.ben/com.github/git.lekuin.stuff/projects/ocamljs/ocamljs-read-only/test/jslib'
  7 ocamlbuild main.byte --
  8 ..
  9 Ran: 2 tests in: 0.00 seconds.
 10 OKmake[2]: Leaving directory `/var/userdata/it/lekuin.ben/com.github/git.lekuin.stuff/projects/ocamljs/ocamljs-read-only/test/jslib'
 11 make[2]: Entering directory `/var/userdata/it/lekuin.ben/com.github/git.lekuin.stuff/projects/ocamljs/ocamljs-read-only/test/ocamljs'
 12 ocamlbuild main.js;
 13 js _build/main.js
 14 _build/main.js:294: ReferenceError: print_verbatim is not defined
 15 make[2]: *** [all] Error 3
 16 make[2]: Leaving directory `/var/userdata/it/lekuin.ben/com.github/git.lekuin.stuff/projects/ocamljs/ocamljs-read-only/test/ocamljs'
 17 make[1]: *** [all] Error 2
 18 make[1]: Leaving directory `/var/userdata/it/lekuin.ben/com.github/git.lekuin.stuff/proects/ocamljs/ocamljs-read-only/test'
 19 make: *** [test] Error 2

'


Jake Donham

unread,
Dec 20, 2009, 11:43:27 PM12/20/09
to ocamljs...@googlegroups.com
Hi Ben, thanks for the bug report.

The reason for this error is that in order to get printing to stdout
working (in order to get oUnit working) I had to add a primitive to
the SpiderMonkey Javascript interpreter; the built-in print primitive
adds a newline to everything. The patch follows (against SpiderMonkey
1.60).

I'm not sure what is the right way to handle this so that everybody
can run the tests. As far as I know there is no way to extend
SpiderMonkey without recompiling it. The only other thing I can think
of is some ungodly hack like pipe the js output through a filter that
strips the extra newlines. Or ship a patched SpiderMonkey (or some
other Javascript interpreter) with ocamljs.

Jake

diff -r js/src/js.c js.patched/src/js.c
689a690,705
> Print_verbatim(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
> {
> uintN i, n;
> JSString *str;
>
> for (i = n = 0; i < argc; i++) {
> str = JS_ValueToString(cx, argv[i]);
> if (!str)
> return JS_FALSE;
> fprintf(gOutFile, "%s", JS_GetStringBytes(str));
> }
> n++;
> return JS_TRUE;
> }
>
> static JSBool
1620a1637
> {"print_verbatim", Print_verbatim, 0},

> --
>
> You received this message because you are subscribed to the Google Groups
> "ocamljs discuss" group.
> To post to this group, send email to ocamljs...@googlegroups.com.
> To unsubscribe from this group, send email to
> ocamljs-discu...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/ocamljs-discuss?hl=en.
>

ben kuin

unread,
Dec 21, 2009, 12:10:26 PM12/21/09
to ocamljs...@googlegroups.com
thanks for the explanation. my 3 cents:

1. I think the best way would be a solution who is as predictable as possible. I have bad experiences with filters in this regard.

2. I wouldn't overwrite js 'print()' function either. Maybe you'll need it someday.

3. The best would be a native 'echo()' command. I think the closest in native javascript would be 'document.write()'. Somebody already built a spidermonkey mod: http://blog.didierstevens.com/programs/spidermonkey/.
Reply all
Reply to author
Forward
0 new messages