diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-10-20 18:36:30 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-10-20 18:36:30 -0700 |
commit | 25c6032a589f751573d0623645163fcd03192fc2 (patch) | |
tree | ee7c3351e59fa4a0b5935ce07105da26f83d2710 | |
parent | 2781c7dca6685dbb4519f1bf77c3d3f4611b0f90 (diff) |
check node version is at least 0.6.8, which is the first to not have v8 bug 1895; enable crankshaft in js optimizer for additional speed
-rwxr-xr-x | tests/runner.py | 44 | ||||
-rw-r--r-- | tools/shared.py | 24 |
2 files changed, 63 insertions, 5 deletions
diff --git a/tests/runner.py b/tests/runner.py index a419ff0d..41b9ee19 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -9725,6 +9725,50 @@ elif 'sanity' in str(sys.argv): finally: del os.environ['EM_IGNORE_SANITY'] + def test_node(self): + NODE_WARNING = 'warning: node version appears too old' + NODE_WARNING_2 = 'warning: cannot check node version' + + restore() + + # Clang should report the version number we expect, and emcc should not warn + assert check_node_version() + output = self.check_working(EMCC) + assert NODE_WARNING not in output, output + + # Fake a different node version + restore() + f = open(CONFIG_FILE, 'a') + f.write('NODE_JS = "' + path_from_root('tests', 'fake', 'nodejs') + '"') + f.close() + + if not os.path.exists(path_from_root('tests', 'fake')): + os.makedirs(path_from_root('tests', 'fake')) + + try: + os.environ['EM_IGNORE_SANITY'] = '1' + for version, succeed in [(('v0.6.6'), False), (('v0.6.7'), False), (('v0.6.8'), True), (('v0.6.9'), True), (('v0.7.1'), True), (('v0.7.9'), True), (('v0.8.7'), True), (('v0.8.9'), True), ('cheez', False)]: + f = open(path_from_root('tests', 'fake', 'nodejs'), 'w') + f.write('#!/bin/sh\n') + f.write('''if [ $1 = "--version" ]; then + echo "%s" +else + %s $@ +fi +''' % (version, NODE_JS)) + f.close() + os.chmod(path_from_root('tests', 'fake', 'nodejs'), stat.S_IREAD | stat.S_IWRITE | stat.S_IEXEC) + if not succeed: + if version[0] == 'v': + self.check_working(EMCC, NODE_WARNING) + else: + self.check_working(EMCC, NODE_WARNING_2) + else: + output = self.check_working(EMCC) + assert NODE_WARNING not in output, output + finally: + del os.environ['EM_IGNORE_SANITY'] + def test_emcc(self): SANITY_MESSAGE = 'Emscripten: Running sanity checks' SANITY_FAIL_MESSAGE = 'sanity check failed to run' diff --git a/tools/shared.py b/tools/shared.py index ff3c11f2..37552b09 100644 --- a/tools/shared.py +++ b/tools/shared.py @@ -77,17 +77,29 @@ def check_clang_version(): actual = Popen([CLANG, '-v'], stderr=PIPE).communicate()[1].split('\n')[0] if expected in actual: return True - print >> sys.stderr, 'warning: LLVM version appears incorrect (seeing "%s", expected "%s")' % (actual, expected) return False - def check_llvm_version(): try: check_clang_version(); except Exception, e: print >> sys.stderr, 'warning: Could not verify LLVM version: %s' % str(e) +EXPECTED_NODE_VERSION = (0,6,8) + +def check_node_version(): + try: + actual = Popen([NODE_JS, '--version'], stdout=PIPE).communicate()[0].strip() + version = tuple(map(int, actual.replace('v', '').split('.'))) + if version >= EXPECTED_NODE_VERSION: + return True + print >> sys.stderr, 'warning: node version appears too old (seeing "%s", expected "%s")' % (actual, 'v' + ('.'.join(map(str, EXPECTED_NODE_VERSION)))) + return False + except Exception, e: + print >> sys.stderr, 'warning: cannot check node version:', e + return False + # Check that basic stuff we need (a JS engine to compile, Node.js, and Clang and LLVM) # exists. # The test runner always does this check (through |force|). emcc does this less frequently, @@ -110,7 +122,9 @@ def check_sanity(force=False): print >> sys.stderr, '(Emscripten: Config file changed, clearing cache)' # LLVM may have changed, etc. Cache.erase() - check_llvm_version() # just a warning, not a fatal check - do it even if EM_IGNORE_SANITY is on + # some warning, not fatal checks - do them even if EM_IGNORE_SANITY is on + check_llvm_version() + check_node_version() if os.environ.get('EM_IGNORE_SANITY'): print >> sys.stderr, 'EM_IGNORE_SANITY set, ignoring sanity checks' @@ -964,8 +978,8 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)''' % { 'winfix': '' if not WINDOWS e if type(passes) == str: passes = [passes] - # XXX disable crankshaft to work around v8 bug 1895 - output = Popen([NODE_JS, '--nocrankshaft', JS_OPTIMIZER, filename] + passes, stdout=PIPE).communicate()[0] + # XXX Use '--nocrankshaft' to disable crankshaft to work around v8 bug 1895, needed for older v8/node (node 0.6.8+ should be ok) + output = Popen([NODE_JS, JS_OPTIMIZER, filename] + passes, stdout=PIPE).communicate()[0] assert len(output) > 0 and not output.startswith('Assertion failed'), 'Error in js optimizer: ' + output filename += '.jo.js' f = open(filename, 'w') |