kripken / ammo.js

Direct port of the Bullet physics engine to JavaScript using Emscripten
Other
4.18k stars 559 forks source link

Error running the tests #113

Open yomboprime opened 9 years ago

yomboprime commented 9 years ago

I want to make a pull request with some additions to the ammo.idl file. But I have problems running the test.py tests. With the latest ammo and emscripten master branches, and no modified idl, it compiles all right the temp.js, but gives this error when doing the tests:

$ python test.py
Using build: builds/temp.js

===================================

0 : regression tests
      basics.js
Traceback (most recent call last):
  File "test.py", line 43, in <module>
    output = run(fullname)
  File "test.py", line 24, in run
    if JS_ENGINE[0] == SPIDERMONKEY_ENGINE[0]:
IndexError: string index out of range

Please, any help?

kripken commented 9 years ago

I think it expects ~/.emscripten to define both JS_ENGINES and SPIDERMONKEY_ENGINE, and both should be arrays. For example the relevant part of my ~/.emscripten is


NODE_JS = ['/home/alon/Dev/node-v0.10.26/node', '--stack_size=16384']
SPIDERMONKEY_ENGINE = ['/home/alon/Dev/mozilla-inbound/js/src/fast/js/src/js']

JS_ENGINES = [NODE_JS, SPIDERMONKEY_ENGINE]
kripken commented 9 years ago

(note how SPIDERMONKEY_ENGINE is an array even though it has just one element)

yomboprime commented 9 years ago

Thanks for the response. I had SPIDERMONKEY_ENGINE = ''. Setting it to 'nodejs' gives the error:

$ python test.py
Using build: builds/temp.js

===================================

0 : regression tests
      basics.js
Traceback (most recent call last):
  File "test.py", line 44, in <module>
    assert 'ok.' in output, output
AssertionError

And changing it to SPIDERMONKEY_ENGINE = ['nodejs'] gives this error:

$ python test.py
Using build: builds/temp.js

===================================

0 : regression tests
      basics.js

[eval]:1
gcparam("maxBytes", 1024*1024*1024); load("builds/temp.js"); load("tests/testu
^
ReferenceError: gcparam is not defined
    at [eval]:1:1
    at Object.<anonymous> ([eval]-wrapper:6:22)
    at Module._compile (module.js:456:26)
    at evalScript (node.js:536:25)
    at startup (node.js:80:7)
    at node.js:906:3
Traceback (most recent call last):
  File "test.py", line 44, in <module>
    assert 'ok.' in output, output
AssertionError
kripken commented 9 years ago

Try removing SPIDERMONKEY_ENGINE from the list of JS_ENGINES, and editing test.py to use NODE_JS instead of SPIDERMONKEY_ENGINE.

yomboprime commented 9 years ago

Thanks. I've made it use the NODE_JS engine and now it gives this error:

$ python test.py
Using build: builds/temp.js

===================================

0 : regression tests
      basics.js
Traceback (most recent call last):
  File "test.py", line 45, in <module>
    assert 'ok.' in output, output
AssertionError

Sorry I don't know how to debug further. Here is my .emscripten:

import os
SPIDERMONKEY_ENGINE = ''
NODE_JS = 'nodejs'
LLVM_ROOT='/media/datos/soft/emscripten/emsdk_portable/clang/tag-e1.34.6/build_tag-e1.34.6_32/bin'
EMSCRIPTEN_ROOT='/media/datos/soft/emscripten/emsdk_portable/emscripten/tag-1.34.6'
EMSCRIPTEN_NATIVE_OPTIMIZER='/media/datos/soft/emscripten/emsdk_portable/emscripten/tag-1.34.6_32bit_optimizer/optimizer'
V8_ENGINE = ''
TEMP_DIR = '/tmp'
COMPILER_ENGINE = NODE_JS
JS_ENGINES = [NODE_JS]

And the modified lines in test.py:

#JS_ENGINE = SPIDERMONKEY_ENGINE
JS_ENGINE = COMPILER_ENGINE
#JS_ENGINE = V8_ENGINE # Note: fails stress due to floating point differences

if type(JS_ENGINE) == str:
  JS_ENGINE = [JS_ENGINE]

print
print '==================================='
print

def run(filename):
  #if JS_ENGINE[0] == SPIDERMONKEY_ENGINE[0]:
  #  cmd = JS_ENGINE + ['-e', 'gcparam("maxBytes", 1024*1024*1024); load("' + build + '"); load("' + os.path.join('tests', 'testutils.js') + '")', filename]
  #  return Popen(cmd, stdout=PIPE).communicate()[0]
  #else:
  return Popen(JS_ENGINE + [build, os.path.join('tests', 'testutils.js'), filename], stdout=PIPE).communicate()[0]
yomboprime commented 9 years ago

If I set it to this, I get the "gcparam is not defined" error:

def run(filename):
  #if JS_ENGINE[0] == SPIDERMONKEY_ENGINE[0]:
  cmd = JS_ENGINE + ['-e', 'gcparam("maxBytes", 1024*1024*1024); load("' + build + '"); load("' + os.path.join('tests', 'testutils.js') + '")', filename]
  return Popen(cmd, stdout=PIPE).communicate()[0]
  #else:
  #return Popen(JS_ENGINE + [build, os.path.join('tests', 'testutils.js'), filename], stdout=PIPE).communicate()[0]
kripken commented 9 years ago

It might be simpler to just run the tests directly yourself. I think you can run the test .js files in node, if you pass it both the ammo.js file and the test file together.

yomboprime commented 9 years ago

Yes, it worked all right by copying the ammo.js to tests/ and by nodejs ammo.js theTestFile.js for each one.

If no output means test passed, then it passed all the tests :-)

Making the pull request...

guzzard commented 6 years ago

I'm getting a different error:

Using build: builds/ammo.js

===================================

0 : regression tests
      basics.js
Traceback (most recent call last):
  File "./test.py", line 51, in <module>
    output = run(fullname)
  File "./test.py", line 32, in run
    return Popen(cmd, stdout=PIPE).communicate()[0]
  File "/usr/lib/python2.7/subprocess.py", line 390, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1025, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory

Missing a python dep?

kripken commented 6 years ago

The tests might hardcode the JS engine in there, so you could need to edit test.py a little.

guzzard commented 6 years ago

Ah ok, understood!