aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2011-12-19 15:37:47 -0800
committerAlon Zakai <alonzakai@gmail.com>2011-12-19 15:37:47 -0800
commit029499a342c6f0ada3e6ab50eeee3442f68dcdfd (patch)
tree72d757f1d6b876d165346300ef64bca91ea42949
parentf83532997b8ab16201fd75abb0dc94790a53d26d (diff)
fix closure compiler warning in emcc and add sanity test
-rwxr-xr-xemcc2
-rw-r--r--tests/runner.py40
2 files changed, 36 insertions, 6 deletions
diff --git a/emcc b/emcc
index 460f0b79..3e666bb3 100755
--- a/emcc
+++ b/emcc
@@ -284,7 +284,7 @@ try:
if closure is None: closure = 1 if opt_level >= 2 else 0
if closure:
- assert os.path.exists(shared.CLOSURE_COMPILER), 'emcc: fatal: Closure compiler (%s) does not exist' % CLOSURE_COMPILER
+ assert os.path.exists(shared.CLOSURE_COMPILER), 'emcc: fatal: Closure compiler (%s) does not exist' % shared.CLOSURE_COMPILER
settings_changes = []
for i in range(len(newargs)):
diff --git a/tests/runner.py b/tests/runner.py
index f4cfe312..3806d8ea 100644
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -5370,15 +5370,17 @@ elif 'sanity' in str(sys.argv):
return Popen(command, stdout=PIPE, stderr=STDOUT).communicate()[0]
- def check_working(self, command):
+ def check_working(self, command, expected=None):
if type(command) is not list:
command = [command]
+ if expected is None:
+ if command[0] == EMCC:
+ expected = 'no input files'
+ else:
+ expected = "has no attribute 'blahblah'"
output = self.do(command)
- if command[0] == EMCC:
- self.assertContained('no input files', output)
- else:
- self.assertContained("has no attribute 'blahblah'", output)
+ self.assertContained(expected, output)
return output
def test_aaa_normal(self): # this should be the very first thing that runs. if this fails, everything else is irrelevant!
@@ -5413,6 +5415,34 @@ elif 'sanity' in str(sys.argv):
else:
self.assertContained('FATAL', output) # sanity check should fail
+ def test_closure_compiler(self):
+ CLOSURE_FATAL = 'fatal: Closure compiler'
+ CLOSURE_WARNING = 'WARNING: Closure compiler'
+
+ # Sanity check should find closure
+ restore()
+ output = self.check_working(EMCC)
+ self.assertNotContained(CLOSURE_FATAL, output)
+ self.assertNotContained(CLOSURE_WARNING, output)
+
+ # Append a bad path for closure, will warn
+ f = open(CONFIG_FILE, 'a')
+ f.write('CLOSURE_COMPILER = "/tmp/nowhere/nothingtoseehere/kjadsfkjwelkjsdfkqgas/nonexistent.txt"\n')
+ f.close()
+ output = self.check_working(EMCC, CLOSURE_WARNING)
+
+ # And if you actually try to use the bad path, will be fatal
+ f = open(CONFIG_FILE, 'a')
+ f.write('CLOSURE_COMPILER = "/tmp/nowhere/nothingtoseehere/kjadsfkjwelkjsdfkqgas/nonexistent.txt"\n')
+ f.close()
+ output = self.check_working([EMCC, '-O2', 'tests/hello_world.cpp'], CLOSURE_FATAL)
+
+ # With a working path, all is well
+ restore()
+ try_delete('a.out.js')
+ output = self.check_working([EMCC, '-O2', 'tests/hello_world.cpp'], 'The relooper optimization can be very slow')
+ assert os.path.exists('a.out.js')
+
def test_emcc(self):
def mtime(filename):
return os.stat(filename).st_mtime