@@ -18,7 +18,6 @@ fn test_invalid_arg() {
18
18
}
19
19
20
20
#[ test]
21
- #[ cfg( unix) ]
22
21
#[ allow( unused_mut) ]
23
22
fn test_id_no_specified_user ( ) {
24
23
let ts = TestScenario :: new ( util_name ! ( ) ) ;
@@ -44,7 +43,6 @@ fn test_id_no_specified_user() {
44
43
}
45
44
46
45
#[ test]
47
- #[ cfg( unix) ]
48
46
fn test_id_single_user ( ) {
49
47
let test_users = [ & whoami ( ) [ ..] ] ;
50
48
@@ -96,7 +94,6 @@ fn test_id_single_user() {
96
94
}
97
95
98
96
#[ test]
99
- #[ cfg( unix) ]
100
97
fn test_id_single_user_non_existing ( ) {
101
98
let args = & [ "hopefully_non_existing_username" ] ;
102
99
let ts = TestScenario :: new ( util_name ! ( ) ) ;
@@ -114,7 +111,6 @@ fn test_id_single_user_non_existing() {
114
111
}
115
112
116
113
#[ test]
117
- #[ cfg( unix) ]
118
114
fn test_id_name ( ) {
119
115
let ts = TestScenario :: new ( util_name ! ( ) ) ;
120
116
for opt in [ "--user" , "--group" , "--groups" ] {
@@ -133,7 +129,6 @@ fn test_id_name() {
133
129
}
134
130
135
131
#[ test]
136
- #[ cfg( unix) ]
137
132
fn test_id_real ( ) {
138
133
let ts = TestScenario :: new ( util_name ! ( ) ) ;
139
134
for opt in [ "--user" , "--group" , "--groups" ] {
@@ -148,7 +143,7 @@ fn test_id_real() {
148
143
}
149
144
150
145
#[ test]
151
- #[ cfg( all ( unix , not( any( target_os = "linux" , target_os = "android" ) ) ) ) ]
146
+ #[ cfg( not( any( target_os = "linux" , target_os = "android" ) ) ) ]
152
147
fn test_id_pretty_print ( ) {
153
148
// `-p` is BSD only and not supported on GNU's `id`
154
149
let username = whoami ( ) ;
@@ -157,7 +152,7 @@ fn test_id_pretty_print() {
157
152
}
158
153
159
154
#[ test]
160
- #[ cfg( all ( unix , not( any( target_os = "linux" , target_os = "android" ) ) ) ) ]
155
+ #[ cfg( not( any( target_os = "linux" , target_os = "android" ) ) ) ]
161
156
fn test_id_password_style ( ) {
162
157
// `-P` is BSD only and not supported on GNU's `id`
163
158
let username = whoami ( ) ;
@@ -166,7 +161,6 @@ fn test_id_password_style() {
166
161
}
167
162
168
163
#[ test]
169
- #[ cfg( unix) ]
170
164
fn test_id_multiple_users ( ) {
171
165
unwrap_or_return ! ( check_coreutil_version(
172
166
util_name!( ) ,
@@ -224,7 +218,6 @@ fn test_id_multiple_users() {
224
218
}
225
219
226
220
#[ test]
227
- #[ cfg( unix) ]
228
221
fn test_id_multiple_users_non_existing ( ) {
229
222
unwrap_or_return ! ( check_coreutil_version(
230
223
util_name!( ) ,
@@ -292,16 +285,19 @@ fn test_id_multiple_users_non_existing() {
292
285
}
293
286
294
287
#[ test]
295
- #[ cfg( unix) ]
288
+ fn test_id_name_or_real_with_default_format ( ) {
289
+ for flag in [ "-n" , "--name" , "-r" , "--real" ] {
290
+ new_ucmd ! ( )
291
+ . arg ( flag)
292
+ . fails ( )
293
+ . stderr_only ( "id: printing only names or real IDs requires -u, -g, or -G\n " ) ;
294
+ }
295
+ }
296
+
297
+ #[ test]
296
298
fn test_id_default_format ( ) {
297
299
let ts = TestScenario :: new ( util_name ! ( ) ) ;
298
300
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
301
for opt2 in [ "--user" , "--group" , "--groups" ] {
306
302
// u/g/G n/r
307
303
let args = [ opt2, opt1] ;
@@ -329,22 +325,32 @@ fn test_id_default_format() {
329
325
}
330
326
331
327
#[ test]
332
- #[ cfg( unix) ]
328
+ fn test_id_zero_with_default_format ( ) {
329
+ for z_flag in [ "-z" , "--zero" ] {
330
+ new_ucmd ! ( )
331
+ . arg ( z_flag)
332
+ . fails ( )
333
+ . stderr_only ( "id: option --zero not permitted in default format\n " ) ;
334
+ }
335
+ }
336
+
337
+ #[ test]
338
+ fn test_id_zero_with_name_or_real ( ) {
339
+ for z_flag in [ "-z" , "--zero" ] {
340
+ for flag in [ "-n" , "--name" , "-r" , "--real" ] {
341
+ new_ucmd ! ( )
342
+ . args ( & [ z_flag, flag] )
343
+ . fails ( )
344
+ . stderr_only ( "id: printing only names or real IDs requires -u, -g, or -G\n " ) ;
345
+ }
346
+ }
347
+ }
348
+
349
+ #[ test]
333
350
fn test_id_zero ( ) {
334
351
let ts = TestScenario :: new ( util_name ! ( ) ) ;
335
352
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
353
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
354
for opt2 in [ "--user" , "--group" , "--groups" ] {
349
355
// u/g/G n/r z
350
356
let args = [ opt2, z_flag, opt1] ;
@@ -429,7 +435,6 @@ fn test_id_context() {
429
435
}
430
436
431
437
#[ test]
432
- #[ cfg( unix) ]
433
438
fn test_id_no_specified_user_posixly ( ) {
434
439
// gnu/tests/id/no-context.sh
435
440
@@ -456,7 +461,7 @@ fn test_id_no_specified_user_posixly() {
456
461
}
457
462
458
463
#[ test]
459
- #[ cfg( all ( unix , not( target_os = "android" ) ) ) ]
464
+ #[ cfg( not( target_os = "android" ) ) ]
460
465
fn test_id_pretty_print_password_record ( ) {
461
466
// `-p` is BSD only and not supported on GNU's `id`.
462
467
// `-P` is our own extension, and not supported by either GNU nor BSD.
0 commit comments