@@ -84,7 +84,6 @@ fn ctest_cfg() -> ctest::TestGenerator {
84
84
cfg
85
85
}
86
86
87
- #[ expect( unused) ]
88
87
fn ctest_next_cfg ( ) -> ctest_next:: TestGenerator {
89
88
ctest_next:: TestGenerator :: new ( )
90
89
}
@@ -176,14 +175,6 @@ fn main() {
176
175
let re = regex:: bytes:: Regex :: new ( r"(?-u:\b)crate::" ) . unwrap ( ) ;
177
176
copy_dir_hotfix ( Path :: new ( "../src" ) , & hotfix_dir, & re, b"::" ) ;
178
177
179
- // FIXME(ctest): Only needed until ctest-next supports all tests.
180
- // Provide a default for targets that don't yet use `ctest-next`.
181
- std:: fs:: write (
182
- format ! ( "{}/main_next.rs" , std:: env:: var( "OUT_DIR" ) . unwrap( ) ) ,
183
- "\n fn main() { println!(\" test result: ok\" ); }\n " ,
184
- )
185
- . unwrap ( ) ;
186
-
187
178
do_cc ( ) ;
188
179
do_ctest ( ) ;
189
180
do_semver ( ) ;
@@ -887,7 +878,8 @@ fn test_windows(target: &str) {
887
878
let gnu = target. contains ( "gnu" ) ;
888
879
let i686 = target. contains ( "i686" ) ;
889
880
890
- let mut cfg = ctest_cfg ( ) ;
881
+ let mut cfg = ctest_next_cfg ( ) ;
882
+ cfg. skip_private ( true ) ;
891
883
if target. contains ( "msvc" ) {
892
884
cfg. flag ( "/wd4324" ) ;
893
885
}
@@ -915,49 +907,46 @@ fn test_windows(target: &str) {
915
907
[ !gnu] : "Winsock2.h" ,
916
908
}
917
909
918
- cfg. type_name ( move |ty, is_struct , is_union | {
910
+ cfg. rename_struct_ty ( |ty| {
919
911
match ty {
920
912
// Just pass all these through, no need for a "struct" prefix
921
- "FILE" | "DIR" | "Dl_info" => ty. to_string ( ) ,
922
-
913
+ "FILE" | "DIR" | "Dl_info" => ty. to_string ( ) . into ( ) ,
914
+ t if t. ends_with ( "_t" ) => t. to_string ( ) . into ( ) ,
915
+ // Windows uppercase structs don't have `struct` in fr.into()ont:
916
+ t if ty. chars ( ) . next ( ) . unwrap ( ) . is_uppercase ( ) => t. to_string ( ) . into ( ) ,
917
+ "stat" => "struct __stat64" . to_string ( ) . into ( ) ,
918
+ "utimbuf" => "struct __utimbuf64" . to_string ( ) . into ( ) ,
919
+ _ => None ,
920
+ }
921
+ } ) ;
922
+ cfg. rename_type ( move |ty| {
923
+ match ty {
923
924
// FIXME(windows): these don't exist:
924
- "time64_t" => "__time64_t" . to_string ( ) ,
925
- "ssize_t" => "SSIZE_T" . to_string ( ) ,
926
-
927
- "sighandler_t" if !gnu => "_crt_signal_t" . to_string ( ) ,
928
- "sighandler_t" if gnu => "__p_sig_fn_t" . to_string ( ) ,
929
-
930
- t if is_union => format ! ( "union {t}" ) ,
931
- t if t. ends_with ( "_t" ) => t. to_string ( ) ,
925
+ "time64_t" => "__time64_t" . to_string ( ) . into ( ) ,
926
+ "ssize_t" => "SSIZE_T" . to_string ( ) . into ( ) ,
932
927
933
- // Windows uppercase structs don't have `struct` in front:
934
- t if is_struct => {
935
- if ty. chars ( ) . next ( ) . unwrap ( ) . is_uppercase ( ) {
936
- t. to_string ( )
937
- } else if t == "stat" {
938
- "struct __stat64" . to_string ( )
939
- } else if t == "utimbuf" {
940
- "struct __utimbuf64" . to_string ( )
941
- } else {
942
- // put `struct` in front of all structs:
943
- format ! ( "struct {t}" )
944
- }
945
- }
946
- t => t. to_string ( ) ,
928
+ "sighandler_t" if !gnu => "_crt_signal_t" . to_string ( ) . into ( ) ,
929
+ "sighandler_t" if gnu => "__p_sig_fn_t" . to_string ( ) . into ( ) ,
930
+ _ => None ,
947
931
}
948
932
} ) ;
949
933
950
- cfg. fn_cname ( move |name, cname| cname. unwrap_or ( name) . to_string ( ) ) ;
934
+ cfg. rename_fn ( move |func| {
935
+ func. link_name ( )
936
+ . map ( |l| l. to_string ( ) )
937
+ . or ( func. ident ( ) . to_string ( ) . into ( ) )
938
+ } ) ;
951
939
952
- cfg. skip_type ( move |name | match name {
940
+ cfg. skip_alias ( move |alias | match alias . ident ( ) {
953
941
"SSIZE_T" if !gnu => true ,
954
942
"ssize_t" if !gnu => true ,
955
943
// FIXME(windows): The size and alignment of this type are incorrect
956
944
"time_t" if gnu && i686 => true ,
957
945
_ => false ,
958
946
} ) ;
959
947
960
- cfg. skip_struct ( move |ty| {
948
+ cfg. skip_struct ( move |struct_| {
949
+ let ty = struct_. ident ( ) ;
961
950
if ty. starts_with ( "__c_anonymous_" ) {
962
951
return true ;
963
952
}
@@ -967,9 +956,10 @@ fn test_windows(target: &str) {
967
956
_ => false ,
968
957
}
969
958
} ) ;
959
+ cfg. skip_union ( move |union_| union_. ident ( ) . starts_with ( "__c_anonymous_" ) ) ;
970
960
971
- cfg. skip_const ( move |name | {
972
- match name {
961
+ cfg. skip_const ( move |constant | {
962
+ match constant . ident ( ) {
973
963
// FIXME(windows): API error:
974
964
// SIG_ERR type is "void (*)(int)", not "int"
975
965
"SIG_ERR" |
@@ -981,10 +971,7 @@ fn test_windows(target: &str) {
981
971
}
982
972
} ) ;
983
973
984
- cfg. skip_field ( move |s, field| match s {
985
- "CONTEXT" if field == "Fp" => true ,
986
- _ => false ,
987
- } ) ;
974
+ cfg. skip_struct_field ( move |s, field| s. ident ( ) == "CONTEXT" && field. ident ( ) == "Fp" ) ;
988
975
// FIXME(windows): All functions point to the wrong addresses?
989
976
cfg. skip_fn_ptrcheck ( |_| true ) ;
990
977
@@ -999,16 +986,16 @@ fn test_windows(target: &str) {
999
986
}
1000
987
} ) ;
1001
988
1002
- cfg. skip_fn ( move |name | {
1003
- match name {
989
+ cfg. skip_fn ( move |func | {
990
+ match func . ident ( ) {
1004
991
// FIXME: https://github.com/rust-lang/libc/issues/1272
1005
992
"execv" | "execve" | "execvp" | "execvpe" => true ,
1006
993
1007
994
_ => false ,
1008
995
}
1009
996
} ) ;
1010
997
1011
- cfg. generate ( src_hotfix_dir ( ) . join ( " lib.rs") , "ctest_output.rs" ) ;
998
+ ctest_next :: generate_test ( & mut cfg, "../src/ lib.rs", "ctest_output.rs" ) . unwrap ( ) ;
1012
999
}
1013
1000
1014
1001
fn test_redox ( target : & str ) {
0 commit comments