UNPKG

1.97 kBPlain TextView Raw
1import os, sys, re, json
2from subprocess import Popen, PIPE, STDOUT
3
4# By default use builds/ammo.js. Or the commandline argument can override that.
5build = os.path.join('builds', 'temp.js')
6if len(sys.argv) > 1:
7 build = sys.argv[1]
8print 'Using build:', build
9
10exec(open(os.path.expanduser('~/.emscripten'), 'r').read())
11
12# JS_ENGINE = NODE_JS
13#JS_ENGINE = V8_ENGINE # Note: fails stress due to floating point differences
14
15if type(JS_ENGINE) == str:
16 JS_ENGINE = [JS_ENGINE]
17
18
19print
20print '==================================='
21print
22
23def run(filename):
24 if JS_ENGINE[0] == SPIDERMONKEY_ENGINE[0]:
25 cmd = JS_ENGINE + ['-e', 'gcparam("maxBytes", 1024*1024*1024); load("' + build + '"); load("' + os.path.join('tests', 'testutils.js') + '")', filename]
26 return Popen(cmd, stdout=PIPE).communicate()[0]
27 else:
28 return Popen(JS_ENGINE + [build, os.path.join('tests', 'testutils.js'), filename], stdout=PIPE).communicate()[0]
29
30__counter = 0
31def stage(text):
32 global __counter
33 print __counter, ':', text
34 __counter += 1
35
36if len(sys.argv) != 3 or sys.argv[2] != 'benchmark':
37 stage('regression tests')
38
39 for test in ['basics', 'wrapping', '2', '3', 'constraint', 'compoundShape']:
40 name = test + '.js'
41 print ' ', name
42 fullname = os.path.join('tests', name)
43 output = run(fullname)
44 assert 'ok.' in output, output
45
46 stage('hello world')
47
48 output = run(os.path.join('examples', 'hello_world.js'))
49 #assert open(os.path.join('examples', 'hello_world.txt')).read() in output, output
50 assert 'ok.' in output, output
51
52stage('stress')
53
54output = run(os.path.join('tests', 'stress.js'))
55#assert
56'''
570 : 0.00,-56.00,0.00
581 : 13.03,-5.00,-5.24
592 : 2.43,-5.00,-3.49
603 : -6.77,-5.54,-0.77
614 : -2.55,-5.00,2.84
625 : 11.75,-5.00,11.25
636 : 2.35,-5.61,0.12
64total time:''' in output#, output
65assert 'ok.' in output, output
66print ' stress benchmark: ' + output.split('\n')[-3]
67
68print
69print '==================================='
70print
71print 'ok.'