diff --git a/catkin_tools/runner/run_unix.py b/catkin_tools/runner/run_unix.py index 7359dd4a..70886ab1 100644 --- a/catkin_tools/runner/run_unix.py +++ b/catkin_tools/runner/run_unix.py @@ -27,7 +27,7 @@ def process_incomming_lines(lines, left_over): if not lines: return None, left_over - if lines[-1].rstrip() != lines[-1]: + if str(lines[-1]).endswith('\n'): data = b''.join(lines) left_over = b'' else: @@ -64,8 +64,8 @@ def run_command(cmd, cwd=None): data, left_over = process_incomming_lines(lines, left_over) if data is None: continue - yield data + yield str(data) # Done os.close(master) - yield p.returncode + yield int(p.returncode) diff --git a/tests/utils.py b/tests/utils.py index e809647c..b6660e1f 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -93,6 +93,7 @@ class temporary_directory(object): def __init__(self, prefix=''): self.prefix = prefix + self.delete = False def __enter__(self): self.original_cwd = os.getcwd() @@ -101,7 +102,8 @@ def __enter__(self): return self.temp_path def __exit__(self, exc_type, exc_value, traceback): - if self.temp_path and os.path.exists(self.temp_path): + if self.delete and self.temp_path and os.path.exists(self.temp_path): + print('Deleting temporary testind directory: %s' % self.temp_path) shutil.rmtree(self.temp_path) if self.original_cwd and os.path.exists(self.original_cwd): os.chdir(self.original_cwd) @@ -139,22 +141,16 @@ def run(args, **kwargs): Call to Popen, returns (errcode, stdout, stderr) """ print("run:", args) - with tempfile.NamedTemporaryFile(mode='w+') as temp_buffer: - p = subprocess.Popen( - args, - stdout=temp_buffer, - stderr=subprocess.STDOUT, - universal_newlines=True, - cwd=kwargs.get('cwd', os.getcwd())) - print("P==", p.__dict__) - print("Dumping stdout to: "+ temp_buffer.name) - p.wait() - temp_buffer.seek(0) - stdout = temp_buffer.read() - - return (p.returncode, stdout, '') - - return (None, None, None) + p = subprocess.Popen( + args, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + universal_newlines=True, + cwd=kwargs.get('cwd', os.getcwd())) + print("P==", p.__dict__) + (stdout, stderr) = p.communicate() + + return (p.returncode, stdout, stderr) def assert_cmd_success(cmd, **kwargs):