def test_command_with_stdin(self): """Test that cli() can handle string input.""" stdin = 'hi\nthere\n' subcommand = '{wc} -l | {grep} -q 2'.format(wc=shutil.which('wc'), grep=shutil.which('grep')) operation = commandline.cli(command=['/bin/sh', '-c', subcommand], shell=False, stdin=stdin) assert operation.output.returncode.result() == 0 operation = commandline.commandline_operation('/bin/sh', ['-c', subcommand], stdin=stdin) assert operation.output.returncode.result() == 0 subcommand = '{wc} -l | {grep} -q 1'.format(wc=shutil.which('wc'), grep=shutil.which('grep')) operation = commandline.cli(command=['/bin/sh', '-c', subcommand], shell=False, stdin=stdin) assert operation.output.returncode.result() != 0 operation = commandline.commandline_operation('/bin/sh', ['-c', subcommand], stdin=stdin) assert operation.output.returncode.result() != 0
def test_true(self): operation = commandline.commandline_operation(executable='true') # Note: getitem not implemented. # assert 'stdout' in operation.output # assert 'stderr' in operation.output assert not hasattr(operation.output, 'erroroutput') assert hasattr(operation.output, 'file') assert hasattr(operation.output, 'stdout') assert hasattr(operation.output, 'stderr') assert hasattr(operation.output, 'returncode') assert operation.output.returncode.result() == 0
def test_true(self): operation = commandline.commandline_operation(executable='true') # Note: 'stdout' and 'stderr' not mapped. # Note: getitem not implemented. # assert not 'stdout' in operation.output # assert not 'stderr' in operation.output assert not hasattr(operation.output, 'stdout') assert not hasattr(operation.output, 'stderr') assert hasattr(operation.output, 'file') assert hasattr(operation.output, 'erroroutput') assert hasattr(operation.output, 'returncode') assert operation.output.returncode.result() == 0
def test_echo(self): # TODO: (FR5+) do we want to pipeline or checkpoint stdout somehow? operation = commandline.commandline_operation(executable='echo', arguments=['hi there']) assert operation.output.returncode.result() == 0
def test_false(self): operation = commandline.commandline_operation(executable='false') assert operation.output.returncode.result() == 1
def test_echo(self): # TODO: (#3549) Check stdout, stderr. operation = commandline.commandline_operation(executable='echo', arguments=['hi there']) assert operation.output.returncode.result() == 0