@@ -78,7 +78,9 @@ fn ctest_cfg() -> ctest::TestGenerator {
78
78
}
79
79
80
80
fn ctest_next_cfg ( ) -> ctest_next:: TestGenerator {
81
- ctest_next:: TestGenerator :: new ( )
81
+ let mut cfg = ctest_next:: TestGenerator :: new ( ) ;
82
+ cfg. skip_private ( true ) ;
83
+ cfg
82
84
}
83
85
84
86
fn do_semver ( ) {
@@ -217,7 +219,8 @@ fn test_apple(target: &str) {
217
219
let x86_64 = target. contains ( "x86_64" ) ;
218
220
let i686 = target. contains ( "i686" ) ;
219
221
220
- let mut cfg = ctest_cfg ( ) ;
222
+ let mut cfg = ctest_next_cfg ( ) ;
223
+
221
224
cfg. flag ( "-Wno-deprecated-declarations" ) ;
222
225
cfg. define ( "__APPLE_USE_RFC_3542" , None ) ;
223
226
@@ -330,11 +333,12 @@ fn test_apple(target: &str) {
330
333
[ x86_64] : "crt_externs.h" ,
331
334
}
332
335
333
- cfg. skip_struct ( move |ty| {
334
- if ty. starts_with ( "__c_anonymous_" ) {
335
- return true ;
336
- }
337
- match ty {
336
+ // Skip anonymous unions/structs.
337
+ cfg. skip_union ( |u| u. ident ( ) . starts_with ( "__c_anonymous_" ) ) ;
338
+ cfg. skip_struct ( |s| s. ident ( ) . starts_with ( "__c_anonymous_" ) ) ;
339
+
340
+ cfg. skip_struct ( |s| {
341
+ match s. ident ( ) {
338
342
// FIXME(macos): The size is changed in recent macOSes.
339
343
"malloc_zone_t" => true ,
340
344
// it is a moving target, changing through versions
@@ -344,16 +348,13 @@ fn test_apple(target: &str) {
344
348
"malloc_introspection_t" => true ,
345
349
// sonoma changes the padding `rmx_filler` field.
346
350
"rt_metrics" => true ,
347
-
348
351
_ => false ,
349
352
}
350
353
} ) ;
351
354
352
- cfg. skip_type ( move |ty| {
353
- if ty. starts_with ( "__c_anonymous_" ) {
354
- return true ;
355
- }
356
- match ty {
355
+ cfg. skip_alias ( |ty| ty. ident ( ) . starts_with ( "__c_anonymous_" ) ) ;
356
+ cfg. skip_alias ( |ty| {
357
+ match ty. ident ( ) {
357
358
// FIXME(macos): Requires the macOS 14.4 SDK.
358
359
"os_sync_wake_by_address_flags_t" | "os_sync_wait_on_address_flags_t" => true ,
359
360
@@ -364,8 +365,8 @@ fn test_apple(target: &str) {
364
365
}
365
366
} ) ;
366
367
367
- cfg. skip_const ( move |name | {
368
- match name {
368
+ cfg. skip_const ( move |constant | {
369
+ match constant . ident ( ) {
369
370
// These OSX constants are removed in Sierra.
370
371
// https://developer.apple.com/library/content/releasenotes/General/APIDiffsMacOS10_12/Swift/Darwin.html
371
372
"KERN_KDENABLE_BG_TRACE" | "KERN_KDDISABLE_BG_TRACE" => true ,
@@ -385,9 +386,9 @@ fn test_apple(target: &str) {
385
386
}
386
387
} ) ;
387
388
388
- cfg. skip_fn ( move |name | {
389
+ cfg. skip_fn ( move |func | {
389
390
// skip those that are manually verified
390
- match name {
391
+ match func . ident ( ) {
391
392
// close calls the close_nocancel system call
392
393
"close" => true ,
393
394
@@ -416,8 +417,8 @@ fn test_apple(target: &str) {
416
417
}
417
418
} ) ;
418
419
419
- cfg. skip_field ( move |struct_, field| {
420
- match ( struct_, field) {
420
+ cfg. skip_struct_field ( move |struct_, field| {
421
+ match ( struct_. ident ( ) , field. ident ( ) ) {
421
422
// FIXME(macos): the array size has been changed since macOS 10.15 ([8] -> [7]).
422
423
( "statfs" , "f_reserved" ) => true ,
423
424
( "__darwin_arm_neon_state64" , "__v" ) => true ,
@@ -430,39 +431,31 @@ fn test_apple(target: &str) {
430
431
}
431
432
} ) ;
432
433
433
- cfg. volatile_item ( |i| {
434
- use ctest:: VolatileItemKind :: * ;
435
- match i {
436
- StructField ( ref n, ref f) if n == "aiocb" && f == "aio_buf" => true ,
437
- _ => false ,
438
- }
434
+ cfg. volatile_struct_field ( |s, f| s. ident ( ) == "aiocb" && f. ident ( ) == "aio_buf" ) ;
435
+
436
+ cfg. rename_struct_ty ( move |ty| {
437
+ // Just pass all these through, no need for a "struct" prefix
438
+ [ "FILE" , "DIR" , "Dl_info" ]
439
+ . contains ( & ty)
440
+ . then_some ( ty. to_string ( ) )
439
441
} ) ;
440
442
441
- cfg. type_name ( move |ty, is_struct, is_union| {
442
- match ty {
443
- // Just pass all these through, no need for a "struct" prefix
444
- "FILE" | "DIR" | "Dl_info" => ty. to_string ( ) ,
443
+ // OSX calls this something else
444
+ cfg. rename_type ( |ty| ( ty == "sighandler_t" ) . then_some ( "sig_t" . to_string ( ) ) ) ;
445
445
446
- // OSX calls this something else
447
- "sighandler_t" => "sig_t" . to_string ( ) ,
446
+ cfg . rename_struct_ty ( |ty| ty . ends_with ( "_t" ) . then_some ( ty . to_string ( ) ) ) ;
447
+ cfg . rename_union_ty ( |ty| ty . ends_with ( "_t" ) . then_some ( ty . to_string ( ) ) ) ;
448
448
449
- t if is_union => format ! ( "union {t}" ) ,
450
- t if t. ends_with ( "_t" ) => t. to_string ( ) ,
451
- t if is_struct => format ! ( "struct {t}" ) ,
452
- t => t. to_string ( ) ,
453
- }
454
- } ) ;
455
-
456
- cfg. field_name ( move |struct_, field| {
457
- match field {
458
- s if s. ends_with ( "_nsec" ) && struct_. starts_with ( "stat" ) => {
459
- s. replace ( "e_nsec" , "espec.tv_nsec" )
449
+ cfg. rename_struct_field ( |s, f| {
450
+ match f. ident ( ) {
451
+ n if n. ends_with ( "_nsec" ) && s. ident ( ) . starts_with ( "stat" ) => {
452
+ Some ( n. replace ( "e_nsec" , "espec.tv_nsec" ) )
460
453
}
461
454
// FIXME(macos): sigaction actually contains a union with two variants:
462
455
// a sa_sigaction with type: (*)(int, struct __siginfo *, void *)
463
456
// a sa_handler with type sig_t
464
- "sa_sigaction" if struct_ == "sigaction" => "sa_handler" . to_string ( ) ,
465
- s => s . to_string ( ) ,
457
+ "sa_sigaction" if s . ident ( ) == "sigaction" => Some ( "sa_handler" . to_string ( ) ) ,
458
+ _ => None ,
466
459
}
467
460
} ) ;
468
461
@@ -473,7 +466,8 @@ fn test_apple(target: &str) {
473
466
"uuid_t" | "vol_capabilities_set_t" => true ,
474
467
_ => false ,
475
468
} ) ;
476
- cfg. generate ( src_hotfix_dir ( ) . join ( "lib.rs" ) , "ctest_output.rs" ) ;
469
+
470
+ ctest_next:: generate_test ( & mut cfg, "../src/lib.rs" , "ctest_output.rs" ) . unwrap ( ) ;
477
471
}
478
472
479
473
fn test_openbsd ( target : & str ) {
@@ -804,7 +798,7 @@ fn test_windows(target: &str) {
804
798
let i686 = target. contains ( "i686" ) ;
805
799
806
800
let mut cfg = ctest_next_cfg ( ) ;
807
- cfg . skip_private ( true ) ;
801
+
808
802
if target. contains ( "msvc" ) {
809
803
cfg. flag ( "/wd4324" ) ;
810
804
}
0 commit comments