コード例 #1
0
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
    }
コード例 #2
0
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
コード例 #3
0
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
    }
コード例 #4
0
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
コード例 #5
0
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']
コード例 #6
0
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']
コード例 #7
0
def test_str():
    cmds = CommandSequence(CommandSequenceBase("opengrok-master",
                                               [{"command": ['foo']},
                                                {"command": ["bar"]}]))
    assert str(cmds) == "opengrok-master"