@@ -291,17 +291,21 @@ fn test_id_multiple_users_non_existing() {
291
291
}
292
292
}
293
293
294
+ #[ test]
295
+ fn test_id_name_or_real_with_default_format ( ) {
296
+ for flag in [ "-n" , "--name" , "-r" , "--real" ] {
297
+ new_ucmd ! ( )
298
+ . arg ( flag)
299
+ . fails ( )
300
+ . stderr_only ( "id: printing only names or real IDs requires -u, -g, or -G\n " ) ;
301
+ }
302
+ }
303
+
294
304
#[ test]
295
305
#[ cfg( unix) ]
296
306
fn test_id_default_format ( ) {
297
307
let ts = TestScenario :: new ( util_name ! ( ) ) ;
298
308
for opt1 in [ "--name" , "--real" ] {
299
- // id: cannot print only names or real IDs in default format
300
- let args = [ opt1] ;
301
- ts. ucmd ( )
302
- . args ( & args)
303
- . fails ( )
304
- . stderr_only ( unwrap_or_return ! ( expected_result( & ts, & args) ) . stderr_str ( ) ) ;
305
309
for opt2 in [ "--user" , "--group" , "--groups" ] {
306
310
// u/g/G n/r
307
311
let args = [ opt2, opt1] ;
@@ -328,23 +332,34 @@ fn test_id_default_format() {
328
332
}
329
333
}
330
334
335
+ #[ test]
336
+ fn test_id_zero_with_default_format ( ) {
337
+ for z_flag in [ "-z" , "--zero" ] {
338
+ new_ucmd ! ( )
339
+ . arg ( z_flag)
340
+ . fails ( )
341
+ . stderr_only ( "id: option --zero not permitted in default format\n " ) ;
342
+ }
343
+ }
344
+
345
+ #[ test]
346
+ fn test_id_zero_with_name_or_real ( ) {
347
+ for z_flag in [ "-z" , "--zero" ] {
348
+ for flag in [ "-n" , "--name" , "-r" , "--real" ] {
349
+ new_ucmd ! ( )
350
+ . args ( & [ z_flag, flag] )
351
+ . fails ( )
352
+ . stderr_only ( "id: printing only names or real IDs requires -u, -g, or -G\n " ) ;
353
+ }
354
+ }
355
+ }
356
+
331
357
#[ test]
332
358
#[ cfg( unix) ]
333
359
fn test_id_zero ( ) {
334
360
let ts = TestScenario :: new ( util_name ! ( ) ) ;
335
361
for z_flag in [ "-z" , "--zero" ] {
336
- // id: option --zero not permitted in default format
337
- ts. ucmd ( )
338
- . args ( & [ z_flag] )
339
- . fails ( )
340
- . stderr_only ( unwrap_or_return ! ( expected_result( & ts, & [ z_flag] ) ) . stderr_str ( ) ) ;
341
362
for opt1 in [ "--name" , "--real" ] {
342
- // id: cannot print only names or real IDs in default format
343
- let args = [ opt1, z_flag] ;
344
- ts. ucmd ( )
345
- . args ( & args)
346
- . fails ( )
347
- . stderr_only ( unwrap_or_return ! ( expected_result( & ts, & args) ) . stderr_str ( ) ) ;
348
363
for opt2 in [ "--user" , "--group" , "--groups" ] {
349
364
// u/g/G n/r z
350
365
let args = [ opt2, z_flag, opt1] ;
0 commit comments