1 | import os, sys, re, json
|
2 | from subprocess import Popen, PIPE, STDOUT
|
3 |
|
4 |
|
5 | build = os.path.join('builds', 'temp.js')
|
6 | if len(sys.argv) > 1:
|
7 | build = sys.argv[1]
|
8 | print 'Using build:', build
|
9 |
|
10 | exec(open(os.path.expanduser('~/.emscripten'), 'r').read())
|
11 |
|
12 |
|
13 |
|
14 |
|
15 | if type(JS_ENGINE) == str:
|
16 | JS_ENGINE = [JS_ENGINE]
|
17 |
|
18 |
|
19 | print
|
20 | print '==================================='
|
21 | print
|
22 |
|
23 | def 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
|
31 | def stage(text):
|
32 | global __counter
|
33 | print __counter, ':', text
|
34 | __counter += 1
|
35 |
|
36 | if 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 |
|
50 | assert 'ok.' in output, output
|
51 |
|
52 | stage('stress')
|
53 |
|
54 | output = run(os.path.join('tests', 'stress.js'))
|
55 |
|
56 | '''
|
57 | 0 : 0.00,-56.00,0.00
|
58 | 1 : 13.03,-5.00,-5.24
|
59 | 2 : 2.43,-5.00,-3.49
|
60 | 3 : -6.77,-5.54,-0.77
|
61 | 4 : -2.55,-5.00,2.84
|
62 | 5 : 11.75,-5.00,11.25
|
63 | 6 : 2.35,-5.61,0.12
|
64 | total time:''' in output
|
65 | assert 'ok.' in output, output
|
66 | print ' stress benchmark: ' + output.split('\n')[-3]
|
67 |
|
68 | print
|
69 | print '==================================='
|
70 | print
|
71 | print 'ok.'
|