def test_terminate_after_non_zero_code(): cmd_list = [{"command": ["/bin/sh", "-c", "echo " + CommandSequence.PROJECT_SUBST + "; exit 255"]}, {"command": ["/bin/echo"]}] cmds = CommandSequence(CommandSequenceBase("opengrok-master", cmd_list)) cmds.run() assert cmds.retcodes == { '/bin/sh -c echo opengrok-master; exit 255': 255 }
def test_exit_2_handling(): cmd_list = [{"command": ["/bin/sh", "-c", "echo " + CommandSequence.PROJECT_SUBST + "; exit 2"]}, {"command": ["/bin/echo"]}] cmds = CommandSequence(CommandSequenceBase("opengrok-master", cmd_list)) cmds.run() assert cmds.retcodes == { '/bin/sh -c echo opengrok-master; exit 2': 2 } assert not cmds.failed
def test_run_retcodes(): cmd_list = [{"command": ["/bin/echo"]}, {"command": ["/bin/sh", "-c", "echo " + CommandSequence.PROJECT_SUBST + "; exit 0"]}, {"command": ["/bin/sh", "-c", "echo " + CommandSequence.PROJECT_SUBST + "; exit 1"]}] cmds = CommandSequence(CommandSequenceBase("opengrok-master", cmd_list)) cmds.run() assert cmds.retcodes == { '/bin/echo opengrok-master': 0, '/bin/sh -c echo opengrok-master; exit 0': 0, '/bin/sh -c echo opengrok-master; exit 1': 1 }
def test_driveon_flag(): cmd_list = [{"command": ["/bin/sh", "-c", "echo " + CommandSequence.PROJECT_SUBST + "; exit 2"]}, {"command": ["/bin/echo"]}, {"command": ["/bin/sh", "-c", "echo " + CommandSequence.PROJECT_SUBST + "; exit 1"]}, {"command": ["/bin/sh", "-c", "echo " + CommandSequence.PROJECT_SUBST]}] cmds = CommandSequence(CommandSequenceBase("opengrok-master", cmd_list, driveon=True)) cmds.run() assert cmds.retcodes == { '/bin/sh -c echo opengrok-master; exit 2': 2, '/bin/echo opengrok-master': 0, '/bin/sh -c echo opengrok-master; exit 1': 1 } assert cmds.failed
def test_project_subst(): cmd_list = [{"command": ["/bin/echo", CommandSequence.PROJECT_SUBST]}] cmds = CommandSequence(CommandSequenceBase("test-subst", cmd_list)) cmds.run() assert cmds.outputs['/bin/echo test-subst'] == ['test-subst\n']
def test_project_subst(): cmd_list = [{"command": ["/bin/echo", PROJECT_SUBST]}] cmds = CommandSequence(CommandSequenceBase("test-subst", cmd_list)) cmds.run() assert cmds.outputs['/bin/echo test-subst'] == ['test-subst\n']
def test_str(): cmds = CommandSequence(CommandSequenceBase("opengrok-master", [{"command": ['foo']}, {"command": ["bar"]}])) assert str(cmds) == "opengrok-master"