Fix test from It did not work when executed in /tmp
because it did not use the method that TestRunExecutorWithContainer
overrides in order to fix the run environment.
@@ -137,30 +137,24 @@ class TestRunExecutor(unittest.TestCase):
if not os.path.exists('/bin/sh'):
self.skipTest('missing /bin/sh')
- def execute_Run_intern(cmd):
- (output_fd, output_filename) = tempfile.mkstemp('.log', 'output_', text=True)
+ def execute_Run_intern(*args, **kwargs):
(error_fd, error_filename) = tempfile.mkstemp('.log', 'error_', text=True)
try:
- self.runexecutor.execute_run(cmd,
- output_filename=output_filename,
- error_filename=error_filename)
- output_lines = os.read(output_fd, 4096).decode().splitlines()
+ (_, output_lines) = self.execute_run(*args, **kwargs, error_filename=error_filename)
error_lines = os.read(error_fd, 4096).decode().splitlines()
return (output_lines, error_lines)
finally:
- os.close(output_fd)
- os.remove(output_filename)
os.close(error_fd)
os.remove(error_filename)
- (output_lines, error_lines) = execute_Run_intern(['/bin/sh', '-c', '""/bin/echo ERROR_TOKEN >&2""'])
+ (output_lines, error_lines) = execute_Run_intern('/bin/sh', '-c', '/bin/echo ERROR_TOKEN >&2')
self.assertEqual(error_lines[-1], 'ERROR_TOKEN', 'run error output misses command output')
for line in output_lines[1:]:
self.assertRegex(line, '^-*$', 'unexpected text in run output')
for line in error_lines[1:-1]:
self.assertRegex(line, '^-*$', 'unexpected text in run error output')
- (output_lines, error_lines) = execute_Run_intern(['/bin/echo', 'OUT_TOKEN'])
+ (output_lines, error_lines) = execute_Run_intern('/bin/echo', 'OUT_TOKEN')
self.check_command_in_output(output_lines, '/bin/echo OUT_TOKEN')
self.check_command_in_output(error_lines, '/bin/echo OUT_TOKEN')
self.assertEqual(output_lines[-1], 'OUT_TOKEN', 'run output misses command output')
