From c2d449216cc48b2980d6e75897b1fa32d0b3c0fb Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Mon, 11 Aug 2014 12:34:15 -0700 Subject: [PATCH] do not emit temp .o files to curr dir, if target is not them; fixes #2644 --- emcc | 3 ++- tests/test_other.py | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/emcc b/emcc index ff79d8752..af26964cc 100755 --- a/emcc +++ b/emcc @@ -1447,7 +1447,8 @@ try: return os.path.join(specified_target, os.path.basename(unsuffixed(input_file))) + default_object_extension return specified_target return unsuffixed(input_file) + final_ending - return unsuffixed(input_file) + default_object_extension + else: + if has_dash_c: return unsuffixed(input_file) + default_object_extension return in_temp(unsuffixed(uniquename(input_file)) + default_object_extension) # First, generate LLVM bitcode. For each input file, we get base.o with bitcode diff --git a/tests/test_other.py b/tests/test_other.py index 224570abc..45570a09a 100644 --- a/tests/test_other.py +++ b/tests/test_other.py @@ -1,4 +1,5 @@ import multiprocessing, os, re, shutil, subprocess, sys +import glob import tools.shared from tools.shared import * from runner import RunnerCore, path_from_root, get_bullet_library, nonfastcomp @@ -3911,3 +3912,19 @@ main(const int argc, const char * const * const argv) self.assertContained('Constructed locale "C"\nThis locale is the global locale.\nThis locale is the C locale.', run_js('a.out.js', args=['C'])) self.assertContained('''Can't construct locale "waka": collate_byname::collate_byname failed to construct for waka''', run_js('a.out.js', args=['waka'], assert_returncode=1)) + def test_cleanup_os(self): + # issue 2644 + def test(args, be_clean): + print args + self.clear() + shutil.copyfile(path_from_root('tests', 'hello_world.c'), 'a.c') + open('b.c', 'w').write(' ') + Popen([PYTHON, EMCC, 'a.c', 'b.c'] + args).communicate() + clutter = glob.glob('*.o') + if be_clean: assert len(clutter) == 0, 'should not leave clutter ' + str(clutter) + else: assert len(clutter) == 2, 'should leave .o files' + test(['-o', 'c.bc'], True) + test(['-o', 'c.js'], True) + test(['-o', 'c.html'], True) + test(['-c'], False) +