def test_run_chained_cmd(sleep_cmd): out = ProgressOutputPipe() commander = Commander(out) commander.run_chained_commands([([ "sh", "-c", "for x in {1..5} a b c d e; do echo $x; %s done" % sleep_cmd ], []), (["grep", "-e", "\\d"], [])]) assert len(out.stdout) == 5 for i in range(1, 5): assert i == int(out.stdout[i - 1])
def test_output_from_chained_command(self): out = CommandOutputPipeBase(False) commander = Commander(out) assert 0 == commander.run_chained_commands([(["echo", "hello world"], []), (["grep", "hello"], [])]) assert out.stdout[0] == "hello world\n"
def test_longer_chained_command(self): commander = Commander() assert 0 == commander.run_chained_commands([(["echo", "hello world"], []), (["sed", "s/hello/mrcat/g"], []), (["sed", "s/mrcat/auohetn/g"], []), (["grep", "auohetn"], [])])
def test_failing_chained_command(self): commander = Commander() assert 1 == commander.run_chained_commands([(["echo", "hello world"], []), (["grep", "auohetn"], [])])
def test_simple_chained_command(self): commander = Commander() assert 0 == commander.run_chained_commands([(["echo", "hello world"], []), (["grep", "hello"], [])])