|
32 | 32 | os.path.join(os.path.dirname(__file__), '..', '..',
|
33 | 33 | 'main', 'python')))
|
34 | 34 |
|
35 |
| -from opengrok_tools.utils.commands import Commands, CommandsBase |
| 35 | +from opengrok_tools.utils.commandsequence import CommandSequence, CommandSequenceBase |
36 | 36 |
|
37 | 37 |
|
38 | 38 | class TestApp(unittest.TestCase):
|
39 | 39 | def test_str(self):
|
40 |
| - cmds = Commands(CommandsBase("opengrok-master", |
41 |
| - [{"command": ['foo']}, {"command": ["bar"]}])) |
| 40 | + cmds = CommandSequence(CommandSequenceBase("opengrok-master", |
| 41 | + [{"command": ['foo']}, {"command": ["bar"]}])) |
42 | 42 | self.assertEqual("opengrok-master", str(cmds))
|
43 | 43 |
|
44 | 44 | @unittest.skipUnless(os.path.exists('/bin/sh') and os.path.exists('/bin/echo'), "requires Unix")
|
45 | 45 | def test_run_retcodes(self):
|
46 |
| - cmds = Commands(CommandsBase("opengrok-master", |
47 |
| - [{"command": ["/bin/echo"]}, |
48 |
| - {"command": ["/bin/sh", "-c", "echo " + Commands.PROJECT_SUBST + "; exit 0"]}, |
49 |
| - {"command": ["/bin/sh", "-c", "echo " + Commands.PROJECT_SUBST + "; exit 1"]}])) |
| 46 | + cmds = CommandSequence(CommandSequenceBase("opengrok-master", |
| 47 | + [{"command": ["/bin/echo"]}, |
| 48 | + {"command": ["/bin/sh", "-c", "echo " + CommandSequence.PROJECT_SUBST + "; exit 0"]}, |
| 49 | + {"command": ["/bin/sh", "-c", "echo " + CommandSequence.PROJECT_SUBST + "; exit 1"]}])) |
50 | 50 | cmds.run()
|
51 | 51 | self.assertEqual({'/bin/echo opengrok-master': 0,
|
52 | 52 | '/bin/sh -c echo opengrok-master; exit 0': 0,
|
53 | 53 | '/bin/sh -c echo opengrok-master; exit 1': 1}, cmds.retcodes)
|
54 | 54 |
|
55 | 55 | @unittest.skipUnless(os.path.exists('/bin/sh') and os.path.exists('/bin/echo'), "requires Unix")
|
56 | 56 | def test_terminate_after_non_zero_code(self):
|
57 |
| - cmds = Commands(CommandsBase("opengrok-master", |
58 |
| - [{"command": ["/bin/sh", "-c", "echo " + Commands.PROJECT_SUBST + "; exit 255"]}, |
| 57 | + cmds = CommandSequence(CommandSequenceBase("opengrok-master", |
| 58 | + [{"command": ["/bin/sh", "-c", "echo " + CommandSequence.PROJECT_SUBST + "; exit 255"]}, |
59 | 59 | {"command": ["/bin/echo"]}]))
|
60 | 60 | cmds.run()
|
61 | 61 | self.assertEqual({'/bin/sh -c echo opengrok-master; exit 255': 255}, cmds.retcodes)
|
62 | 62 |
|
63 | 63 | @unittest.skipUnless(os.path.exists('/bin/sh') and os.path.exists('/bin/echo'), "requires Unix")
|
64 | 64 | def test_exit_2_handling(self):
|
65 |
| - cmds = Commands(CommandsBase("opengrok-master", |
66 |
| - [{"command": ["/bin/sh", "-c", "echo " + Commands.PROJECT_SUBST + "; exit 2"]}, |
| 65 | + cmds = CommandSequence(CommandSequenceBase("opengrok-master", |
| 66 | + [{"command": ["/bin/sh", "-c", "echo " + CommandSequence.PROJECT_SUBST + "; exit 2"]}, |
67 | 67 | {"command": ["/bin/echo"]}]))
|
68 | 68 | cmds.run()
|
69 | 69 | self.assertEqual({'/bin/sh -c echo opengrok-master; exit 2': 2}, cmds.retcodes)
|
70 | 70 | self.assertFalse(cmds.failed)
|
71 | 71 |
|
72 | 72 | @unittest.skipUnless(os.path.exists('/bin/echo'), "requires Unix")
|
73 | 73 | def test_project_subst(self):
|
74 |
| - cmds = Commands(CommandsBase("test-subst", |
75 |
| - [{"command": ["/bin/echo", Commands.PROJECT_SUBST]}])) |
| 74 | + cmds = CommandSequence(CommandSequenceBase("test-subst", |
| 75 | + [{"command": ["/bin/echo", CommandSequence.PROJECT_SUBST]}])) |
76 | 76 | cmds.run()
|
77 | 77 | self.assertEqual(['test-subst\n'],
|
78 | 78 | cmds.outputs['/bin/echo test-subst'])
|
|
0 commit comments