From 82f38266ae5c2c414f5a4cbe2c9d1c19d78ba550 Mon Sep 17 00:00:00 2001 From: "Alon Zakai (kripken)" Date: Sat, 2 Feb 2019 10:46:17 -0800 Subject: [PATCH 1/5] fix regression from 50d1dc2f6c3f58daad047f1ac48e16f2b5da3479 --- tests/test_other.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/tests/test_other.py b/tests/test_other.py index e29ea3133822d..06fac340a2e2e 100644 --- a/tests/test_other.py +++ b/tests/test_other.py @@ -68,11 +68,16 @@ def decorated(self): # Before running the test completely remove the canonical_tmp if os.path.exists(self.canonical_temp_dir): shutil.rmtree(self.canonical_temp_dir) - func(self) - # Make sure the test isn't lying about the fact that it uses - # canonical_tmp - self.assertTrue(os.path.exists(self.canonical_temp_dir)) - shutil.rmtree(self.canonical_temp_dir) + try: + func(self) + finally: + # Make sure the test isn't lying about the fact that it uses + # canonical_tmp + self.assertTrue(os.path.exists(self.canonical_temp_dir)) + # Remove the temp dir in a try-finally, as otherwise if the + # test fails we would not clean it up, and if leak detection + # is set we will show that error instead of the actual one. + shutil.rmtree(self.canonical_temp_dir) return decorated From 834ea123e0c9374be4e6b837adaa84a0de64e146 Mon Sep 17 00:00:00 2001 From: "Alon Zakai (kripken)" Date: Sat, 2 Feb 2019 10:48:55 -0800 Subject: [PATCH 2/5] temp --- tests/test_other.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_other.py b/tests/test_other.py index 06fac340a2e2e..929ab958d9447 100644 --- a/tests/test_other.py +++ b/tests/test_other.py @@ -2337,6 +2337,7 @@ def test_debuginfo(self): err = run_process([PYTHON, EMCC, path_from_root('tests', 'hello_world.cpp')] + args, stdout=PIPE, stderr=PIPE).stderr lines = err.splitlines() if self.is_wasm_backend(): + print('zz waka\n' + err + '\nzz shaka') finalize = [l for l in lines if 'wasm-emscripten-finalize' in l][0] if expect_debug: self.assertIn(' -g ', finalize) From d8e2f75d21d0f264c17ca16197e2a47e09918e73 Mon Sep 17 00:00:00 2001 From: "Alon Zakai (kripken)" Date: Sat, 2 Feb 2019 12:02:28 -0800 Subject: [PATCH 3/5] fix logging --- tests/test_other.py | 1 - tools/shared.py | 4 +++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/test_other.py b/tests/test_other.py index 929ab958d9447..06fac340a2e2e 100644 --- a/tests/test_other.py +++ b/tests/test_other.py @@ -2337,7 +2337,6 @@ def test_debuginfo(self): err = run_process([PYTHON, EMCC, path_from_root('tests', 'hello_world.cpp')] + args, stdout=PIPE, stderr=PIPE).stderr lines = err.splitlines() if self.is_wasm_backend(): - print('zz waka\n' + err + '\nzz shaka') finalize = [l for l in lines if 'wasm-emscripten-finalize' in l][0] if expect_debug: self.assertIn(' -g ', finalize) diff --git a/tools/shared.py b/tools/shared.py index 85dbed863f8c3..e6084b1727710 100644 --- a/tools/shared.py +++ b/tools/shared.py @@ -154,7 +154,9 @@ def run_process(cmd, check=True, input=None, universal_newlines=True, *args, **k kw.setdefault('universal_newlines', True) if hasattr(subprocess, "run"): - return subprocess.run(cmd, check=check, input=input, *args, **kw) + ret = subprocess.run(cmd, check=check, input=input, *args, **kw) + logger.debug('Successfully executed %s' % ' '.join(cmd)) + return ret # Python 2 compatibility: Introduce Python 3 subprocess.run-like behavior if input is not None: From fb7ad40e8e70003e7aa84edfa535b7a1a1e699b3 Mon Sep 17 00:00:00 2001 From: "Alon Zakai (kripken)" Date: Sat, 2 Feb 2019 12:06:48 -0800 Subject: [PATCH 4/5] fix python3 logging --- tools/shared.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/shared.py b/tools/shared.py index e6084b1727710..30d828d98f7aa 100644 --- a/tools/shared.py +++ b/tools/shared.py @@ -153,9 +153,11 @@ def check_returncode(self): def run_process(cmd, check=True, input=None, universal_newlines=True, *args, **kw): kw.setdefault('universal_newlines', True) + debug_text = '%sexecuted %s' % ('successfully ' if check else '', ' '.join(cmd)) + if hasattr(subprocess, "run"): ret = subprocess.run(cmd, check=check, input=input, *args, **kw) - logger.debug('Successfully executed %s' % ' '.join(cmd)) + logger.debug(debug_text) return ret # Python 2 compatibility: Introduce Python 3 subprocess.run-like behavior @@ -166,9 +168,7 @@ def run_process(cmd, check=True, input=None, universal_newlines=True, *args, **k result = Py2CompletedProcess(cmd, proc.returncode, stdout, stderr) if check: result.check_returncode() - logger.debug('Successfully executed %s' % ' '.join(cmd)) - else: - logger.debug('Executed %s' % ' '.join(cmd)) + logger.debug(debug_text) return result From f5d386023877c6f14d75cc7102321b2fef67ce1b Mon Sep 17 00:00:00 2001 From: "Alon Zakai (kripken)" Date: Sat, 2 Feb 2019 13:38:40 -0800 Subject: [PATCH 5/5] remove redundant logging, and test updates --- tests/test_other.py | 15 ++++++++------- tools/shared.py | 1 - 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/test_other.py b/tests/test_other.py index 06fac340a2e2e..34dab946b5acc 100644 --- a/tests/test_other.py +++ b/tests/test_other.py @@ -2343,7 +2343,7 @@ def test_debuginfo(self): else: self.assertNotIn(' -g ', finalize) else: - opts = '\n'.join([l for l in lines if 'LLVM opts:' in l]) + opts = '\n'.join([l for l in lines if os.path.sep + 'opt' in l]) if expect_debug: self.assertNotIn('strip-debug', opts) else: @@ -3556,11 +3556,11 @@ def test_fs_after_main(self): def test_os_oz(self): with env_modify({'EMCC_DEBUG': '1'}): for args, expect in [ - (['-O1'], 'LLVM opts: -O1'), - (['-O2'], 'LLVM opts: -O3'), - (['-Os'], 'LLVM opts: -Os'), - (['-Oz'], 'LLVM opts: -Oz'), - (['-O3'], 'LLVM opts: -O3'), + (['-O1'], '-O1'), + (['-O2'], '-O3'), + (['-Os'], '-Os'), + (['-Oz'], '-Oz'), + (['-O3'], '-O3'), ]: print(args, expect) err = run_process([PYTHON, EMCC, path_from_root('tests', 'hello_world.cpp')] + args, stdout=PIPE, stderr=PIPE).stderr @@ -5876,7 +5876,8 @@ def test(args, llvm_opts=None): if args: assert err.count(VECTORIZE) == 2, err # specified twice, once per file - assert err.count('emcc: LLVM opts: ' + llvm_opts) == 2, err # corresponding to exactly once per invocation of optimizer + # corresponding to exactly once per invocation of optimizer + assert err.count(os.path.sep + 'opt') == 2, err else: assert err.count(VECTORIZE) == 0, err # no optimizations diff --git a/tools/shared.py b/tools/shared.py index 30d828d98f7aa..af28499149d7e 100644 --- a/tools/shared.py +++ b/tools/shared.py @@ -2129,7 +2129,6 @@ def llvm_opt(filename, opts, out=None): else: opts += ['-force-vector-width=4'] - logger.debug('emcc: LLVM opts: ' + ' '.join(opts) + ' [num inputs: ' + str(len(inputs)) + ']') target = out or (filename + '.opt.bc') try: run_process([LLVM_OPT] + inputs + opts + ['-o', target], stdout=PIPE)