30
30
31
31
sys .path .insert (0 , os .path .abspath (
32
32
os .path .join (os .path .dirname (__file__ ), '..' , '..' ,
33
- 'main' , 'python' , 'opengrok_tools' )))
33
+ 'main' , 'python' )))
34
34
35
35
from opengrok_tools .utils .commands import Commands , CommandsBase
36
36
@@ -41,50 +41,38 @@ def test_str(self):
41
41
[{"command" : ['foo' ]}, {"command" : ["bar" ]}]))
42
42
self .assertEqual ("opengrok-master" , str (cmds ))
43
43
44
- @unittest .skipUnless (os .path .exists ('/bin/true ' ) and os .path .exists ('/bin/false ' ), "requires Unix" )
44
+ @unittest .skipUnless (os .path .exists ('/bin/sh ' ) and os .path .exists ('/bin/echo ' ), "requires Unix" )
45
45
def test_run_retcodes (self ):
46
46
cmds = Commands (CommandsBase ("opengrok-master" ,
47
47
[{"command" : ["/bin/echo" ]},
48
- {"command" : ["/bin/true " ]},
49
- {"command" : ["/bin/false " ]}]))
48
+ {"command" : ["/bin/sh" , "-c" , "echo " + Commands . PROJECT_SUBST + "; exit 0 " ]},
49
+ {"command" : ["/bin/sh" , "-c" , "echo " + Commands . PROJECT_SUBST + "; exit 1 " ]}]))
50
50
cmds .run ()
51
- # print(p.retcodes)
52
51
self .assertEqual ({'/bin/echo opengrok-master' : 0 ,
53
- '/bin/true opengrok-master' : 0 ,
54
- '/bin/false opengrok-master' : 1 }, cmds .retcodes )
52
+ '/bin/sh -c echo opengrok-master; exit 0 ' : 0 ,
53
+ '/bin/sh -c echo opengrok-master; exit 1 ' : 1 }, cmds .retcodes )
55
54
56
- @unittest .skipUnless (os .path .exists ('/usr/bin/true' ) and os .path .exists ('/usr/bin/false' ), "requires Unix" )
57
- def test_run_retcodes_usr (self ):
58
- cmds = Commands (CommandsBase ("opengrok-master" ,
59
- [{"command" : ["/bin/echo" ]},
60
- {"command" : ["/usr/bin/true" ]},
61
- {"command" : ["/usr/bin/false" ]}]))
62
- cmds .run ()
63
- # print(p.retcodes)
64
- self .assertEqual ({'/bin/echo opengrok-master' : 0 ,
65
- '/usr/bin/true opengrok-master' : 0 ,
66
- '/usr/bin/false opengrok-master' : 1 }, cmds .retcodes )
67
-
68
- @unittest .skipUnless (os .path .exists ('/bin/true' ) and os .path .exists ('/bin/false' ), "requires Unix" )
55
+ @unittest .skipUnless (os .path .exists ('/bin/sh' ) and os .path .exists ('/bin/echo' ), "requires Unix" )
69
56
def test_terminate_after_non_zero_code (self ):
70
57
cmds = Commands (CommandsBase ("opengrok-master" ,
71
- [{"command" : ["/bin/false " ]},
72
- {"command" : ["/bin/true " ]}]))
58
+ [{"command" : ["/bin/sh" , "-c" , "echo " + Commands . PROJECT_SUBST + "; exit 255 " ]},
59
+ {"command" : ["/bin/echo " ]}]))
73
60
cmds .run ()
74
- self .assertEqual ({'/bin/false opengrok-master' : 1 }, cmds .retcodes )
61
+ self .assertEqual ({'/bin/sh -c echo opengrok-master; exit 255 ' : 255 }, cmds .retcodes )
75
62
76
- @unittest .skipUnless (os .path .exists ('/usr/ bin/true ' ) and os .path .exists ('/usr/ bin/false ' ), "requires Unix" )
77
- def test_terminate_after_non_zero_code_usr (self ):
63
+ @unittest .skipUnless (os .path .exists ('/bin/sh ' ) and os .path .exists ('/bin/echo ' ), "requires Unix" )
64
+ def test_exit_2_handling (self ):
78
65
cmds = Commands (CommandsBase ("opengrok-master" ,
79
- [{"command" : ["/usr/ bin/false " ]},
80
- {"command" : ["/usr/ bin/true " ]}]))
66
+ [{"command" : ["/bin/sh" , "-c" , "echo " + Commands . PROJECT_SUBST + "; exit 2 " ]},
67
+ {"command" : ["/bin/echo " ]}]))
81
68
cmds .run ()
82
- self .assertEqual ({'/usr/bin/false opengrok-master' : 1 }, cmds .retcodes )
69
+ self .assertEqual ({'/bin/sh -c echo opengrok-master; exit 2' : 2 }, cmds .retcodes )
70
+ self .assertFalse (cmds .failed )
83
71
84
- @unittest .skipUnless (os .name . startswith ( "posix" ), "requires Unix" )
72
+ @unittest .skipUnless (os .path . exists ( '/bin/echo' ), "requires Unix" )
85
73
def test_project_subst (self ):
86
74
cmds = Commands (CommandsBase ("test-subst" ,
87
- [{"command" : ["/bin/echo" , '%PROJECT%' ]}]))
75
+ [{"command" : ["/bin/echo" , Commands . PROJECT_SUBST ]}]))
88
76
cmds .run ()
89
77
self .assertEqual (['test-subst\n ' ],
90
78
cmds .outputs ['/bin/echo test-subst' ])
0 commit comments