aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2011-12-11 18:31:10 -0800
committerAlon Zakai <alonzakai@gmail.com>2011-12-11 18:31:10 -0800
commitb1ee96ba0dd86ca8e1f8a14bfd0c48bdd67e58b6 (patch)
tree6853c275f90688feb5876542ca85ff146c08583e
parentd13c1e87d550cb11b3502c10022039a41ac6ab10 (diff)
refactor run_js and an additional emcc test
-rwxr-xr-xemscripten.py2
-rw-r--r--tests/runner.py17
-rw-r--r--tools/shared.py2
3 files changed, 14 insertions, 7 deletions
diff --git a/emscripten.py b/emscripten.py
index 0b08b8f1..f7d1c9cc 100755
--- a/emscripten.py
+++ b/emscripten.py
@@ -140,7 +140,7 @@ def emscript(infile, settings, outfile):
s.write(settings)
s.close()
compiler = path_from_root('src', 'compiler.js')
- shared.run_js(shared.COMPILER_ENGINE, compiler, [settings_file, infile], stdout=outfile, cwd=path_from_root('src'))
+ shared.run_js(compiler, shared.COMPILER_ENGINE, [settings_file, infile], stdout=outfile, cwd=path_from_root('src'))
outfile.close()
diff --git a/tests/runner.py b/tests/runner.py
index 0d54fd34..97adf2f0 100644
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -147,7 +147,7 @@ class RunnerCore(unittest.TestCase):
except:
cwd = None
os.chdir(self.get_dir())
- run_js(engine, filename, args, check_timeout, stdout=open(stdout, 'w'), stderr=open(stderr, 'w'))
+ run_js(filename, engine, args, check_timeout, stdout=open(stdout, 'w'), stderr=open(stderr, 'w'))
if cwd is not None:
os.chdir(cwd)
ret = open(stdout, 'r').read() + open(stderr, 'r').read()
@@ -4915,13 +4915,20 @@ JavaScript in the final linking stage of building.
''' % (shortcompiler, shortcompiler, shortcompiler), output[0], output[1])
- # emcc src.cpp or emcc src.cpp -o src.js ==> should give a .js file
+ # emcc src.cpp ==> writes to a.out.js, much like gcc
try_delete('a.out.js')
output = Popen([compiler, path_from_root('tests', 'hello_world' + suffix)], stdout=PIPE, stderr=PIPE).communicate(input)
assert len(output[0]) == 0, output[0]
#assert len(output[1]) == 0, output[1] # we have some debug warnings there now, FIXME
- assert os.path.exists('a.out.js'), output # should be created in the current directory just like gcc, with a name similar to a.out
- self.assertContained('hello, world!', run_js(None, 'a.out.js'))
+ assert os.path.exists('a.out.js'), output
+ self.assertContained('hello, world!', run_js('a.out.js'))
+
+ # emcc src.cpp -o something.js
+ try_delete('something.js')
+ output = Popen([compiler, path_from_root('tests', 'hello_world' + suffix), '-o', 'something.js'], stdout=PIPE, stderr=PIPE).communicate(input)
+ assert len(output[0]) == 0, output[0]
+ assert os.path.exists('something.js'), output
+ self.assertContained('hello, world!', run_js('something.js'))
# TODO: make sure all of these match gcc
# TODO: when this is done, more test runner to test these (i.e., test all -Ox thoroughly)
@@ -5232,7 +5239,7 @@ if __name__ == '__main__':
def check_engine(engine):
try:
- return 'hello, world!' in run_js(engine, path_from_root('tests', 'hello_world.js'))
+ return 'hello, world!' in run_js(path_from_root('tests', 'hello_world.js'), engine)
except Exception, e:
print 'Checking JS engine %s failed. Check ~/.emscripten. Details: %s' % (str(engine), str(e))
return False
diff --git a/tools/shared.py b/tools/shared.py
index b517c9c7..a63bef9b 100644
--- a/tools/shared.py
+++ b/tools/shared.py
@@ -124,7 +124,7 @@ def timeout_run(proc, timeout, note):
raise Exception("Timed out: " + note)
return proc.communicate()[0]
-def run_js(engine, filename, args=[], check_timeout=False, stdout=PIPE, stderr=None, cwd=None):
+def run_js(filename, engine=None, args=[], check_timeout=False, stdout=PIPE, stderr=None, cwd=None):
if engine is None: engine = JS_ENGINES[0]
if type(engine) is not list: engine = [engine]
return timeout_run(Popen(engine + [filename] + (['--'] if 'd8' in engine[0] else []) + args,