@@ -77,7 +77,6 @@ fn ctest_cfg() -> ctest::TestGenerator {
77
77
ctest:: TestGenerator :: new ( )
78
78
}
79
79
80
- #[ expect( unused) ]
81
80
fn ctest_next_cfg ( ) -> ctest_next:: TestGenerator {
82
81
ctest_next:: TestGenerator :: new ( )
83
82
}
@@ -169,14 +168,6 @@ fn main() {
169
168
let re = regex:: bytes:: Regex :: new ( r"(?-u:\b)crate::" ) . unwrap ( ) ;
170
169
copy_dir_hotfix ( Path :: new ( "../src" ) , & hotfix_dir, & re, b"::" ) ;
171
170
172
- // FIXME(ctest): Only needed until ctest-next supports all tests.
173
- // Provide a default for targets that don't yet use `ctest-next`.
174
- std:: fs:: write (
175
- format ! ( "{}/main_next.rs" , std:: env:: var( "OUT_DIR" ) . unwrap( ) ) ,
176
- "\n fn main() { println!(\" test result: ok\" ); }\n " ,
177
- )
178
- . unwrap ( ) ;
179
-
180
171
do_cc ( ) ;
181
172
do_ctest ( ) ;
182
173
do_semver ( ) ;
@@ -226,7 +217,8 @@ fn test_apple(target: &str) {
226
217
let x86_64 = target. contains ( "x86_64" ) ;
227
218
let i686 = target. contains ( "i686" ) ;
228
219
229
- let mut cfg = ctest_cfg ( ) ;
220
+ let mut cfg = ctest_next_cfg ( ) ;
221
+ cfg. skip_private ( true ) ;
230
222
cfg. flag ( "-Wno-deprecated-declarations" ) ;
231
223
cfg. define ( "__APPLE_USE_RFC_3542" , None ) ;
232
224
@@ -339,11 +331,14 @@ fn test_apple(target: &str) {
339
331
[ x86_64] : "crt_externs.h" ,
340
332
}
341
333
342
- cfg. skip_struct ( move |ty| {
343
- if ty. starts_with ( "__c_anonymous_" ) {
344
- return true ;
345
- }
346
- match ty {
334
+ // Skip anonymous unions/structs.
335
+ cfg. skip_union ( |u| u. ident ( ) . starts_with ( "__c_anonymous_" ) ) ;
336
+ cfg. skip_struct ( |s| s. ident ( ) . starts_with ( "__c_anonymous_" ) ) ;
337
+
338
+ cfg. skip_struct ( |s| {
339
+ match s. ident ( ) {
340
+ // FIXME(union): actually a union
341
+ "sigval" => true ,
347
342
// FIXME(macos): The size is changed in recent macOSes.
348
343
"malloc_zone_t" => true ,
349
344
// it is a moving target, changing through versions
@@ -353,16 +348,13 @@ fn test_apple(target: &str) {
353
348
"malloc_introspection_t" => true ,
354
349
// sonoma changes the padding `rmx_filler` field.
355
350
"rt_metrics" => true ,
356
-
357
351
_ => false ,
358
352
}
359
353
} ) ;
360
354
361
- cfg. skip_type ( move |ty| {
362
- if ty. starts_with ( "__c_anonymous_" ) {
363
- return true ;
364
- }
365
- match ty {
355
+ cfg. skip_alias ( |ty| ty. ident ( ) . starts_with ( "__c_anonymous_" ) ) ;
356
+ cfg. skip_alias ( |ty| {
357
+ match ty. ident ( ) {
366
358
// FIXME(macos): Requires the macOS 14.4 SDK.
367
359
"os_sync_wake_by_address_flags_t" | "os_sync_wait_on_address_flags_t" => true ,
368
360
@@ -373,8 +365,8 @@ fn test_apple(target: &str) {
373
365
}
374
366
} ) ;
375
367
376
- cfg. skip_const ( move |name | {
377
- match name {
368
+ cfg. skip_const ( move |constant | {
369
+ match constant . ident ( ) {
378
370
// These OSX constants are removed in Sierra.
379
371
// https://developer.apple.com/library/content/releasenotes/General/APIDiffsMacOS10_12/Swift/Darwin.html
380
372
"KERN_KDENABLE_BG_TRACE" | "KERN_KDDISABLE_BG_TRACE" => true ,
@@ -394,9 +386,9 @@ fn test_apple(target: &str) {
394
386
}
395
387
} ) ;
396
388
397
- cfg. skip_fn ( move |name | {
389
+ cfg. skip_fn ( move |func | {
398
390
// skip those that are manually verified
399
- match name {
391
+ match func . ident ( ) {
400
392
// close calls the close_nocancel system call
401
393
"close" => true ,
402
394
@@ -425,8 +417,10 @@ fn test_apple(target: &str) {
425
417
}
426
418
} ) ;
427
419
428
- cfg. skip_field ( move |struct_, field| {
429
- match ( struct_, field) {
420
+ cfg. skip_struct_field ( move |struct_, field| {
421
+ match ( struct_. ident ( ) , field. ident ( ) ) {
422
+ // FIXME(union): actually a union
423
+ ( "sigevent" , "sigev_value" ) => true ,
430
424
// FIXME(macos): the array size has been changed since macOS 10.15 ([8] -> [7]).
431
425
( "statfs" , "f_reserved" ) => true ,
432
426
( "__darwin_arm_neon_state64" , "__v" ) => true ,
@@ -439,39 +433,28 @@ fn test_apple(target: &str) {
439
433
}
440
434
} ) ;
441
435
442
- cfg. volatile_item ( |i| {
443
- use ctest:: VolatileItemKind :: * ;
444
- match i {
445
- StructField ( ref n, ref f) if n == "aiocb" && f == "aio_buf" => true ,
446
- _ => false ,
447
- }
448
- } ) ;
449
-
450
- cfg. type_name ( move |ty, is_struct, is_union| {
451
- match ty {
452
- // Just pass all these through, no need for a "struct" prefix
453
- "FILE" | "DIR" | "Dl_info" => ty. to_string ( ) ,
454
-
455
- // OSX calls this something else
456
- "sighandler_t" => "sig_t" . to_string ( ) ,
436
+ cfg. volatile_struct_field ( |s, f| s. ident ( ) == "aiocb" && f. ident ( ) == "aio_buf" ) ;
457
437
458
- t if is_union => format ! ( "union {t}" ) ,
459
- t if t . ends_with ( "_t" ) => t . to_string ( ) ,
460
- t if is_struct => format ! ( "struct {t}" ) ,
461
- t => t . to_string ( ) ,
462
- }
438
+ cfg . rename_struct_ty ( move |ty| {
439
+ // Just pass all these through, no need for a "struct" prefix
440
+ [ "FILE" , "DIR" , "Dl_info" ]
441
+ . contains ( & ty )
442
+ . then_some ( ty . to_string ( ) )
463
443
} ) ;
464
-
465
- cfg. field_name ( move |struct_, field| {
466
- match field {
467
- s if s. ends_with ( "_nsec" ) && struct_. starts_with ( "stat" ) => {
468
- s. replace ( "e_nsec" , "espec.tv_nsec" )
444
+ cfg. rename_type ( |ty| ( ty == "sighandler_t" ) . then_some ( "sig_t" . to_string ( ) ) ) ;
445
+ cfg. rename_struct_ty ( |ty| ty. ends_with ( "_t" ) . then_some ( ty. to_string ( ) ) ) ;
446
+ cfg. rename_union_ty ( |ty| ty. ends_with ( "_t" ) . then_some ( ty. to_string ( ) ) ) ;
447
+
448
+ cfg. rename_struct_field ( |s, f| {
449
+ match f. ident ( ) {
450
+ n if n. ends_with ( "_nsec" ) && s. ident ( ) . starts_with ( "stat" ) => {
451
+ n. replace ( "e_nsec" , "espec.tv_nsec" ) . into ( )
469
452
}
470
453
// FIXME(macos): sigaction actually contains a union with two variants:
471
454
// a sa_sigaction with type: (*)(int, struct __siginfo *, void *)
472
455
// a sa_handler with type sig_t
473
- "sa_sigaction" if struct_ == "sigaction" => "sa_handler" . to_string ( ) ,
474
- s => s . to_string ( ) ,
456
+ "sa_sigaction" if s . ident ( ) == "sigaction" => "sa_handler" . to_string ( ) . into ( ) ,
457
+ _ => None ,
475
458
}
476
459
} ) ;
477
460
@@ -482,7 +465,8 @@ fn test_apple(target: &str) {
482
465
"uuid_t" | "vol_capabilities_set_t" => true ,
483
466
_ => false ,
484
467
} ) ;
485
- cfg. generate ( src_hotfix_dir ( ) . join ( "lib.rs" ) , "ctest_output.rs" ) ;
468
+
469
+ ctest_next:: generate_test ( & mut cfg, "../src/lib.rs" , "ctest_output.rs" ) . unwrap ( ) ;
486
470
}
487
471
488
472
fn test_openbsd ( target : & str ) {
0 commit comments