@@ -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 ( ) ;
@@ -812,7 +803,8 @@ fn test_windows(target: &str) {
812
803
let gnu = target. contains ( "gnu" ) ;
813
804
let i686 = target. contains ( "i686" ) ;
814
805
815
- let mut cfg = ctest_cfg ( ) ;
806
+ let mut cfg = ctest_next_cfg ( ) ;
807
+ cfg. skip_private ( true ) ;
816
808
if target. contains ( "msvc" ) {
817
809
cfg. flag ( "/wd4324" ) ;
818
810
}
@@ -840,49 +832,46 @@ fn test_windows(target: &str) {
840
832
[ !gnu] : "Winsock2.h" ,
841
833
}
842
834
843
- cfg. type_name ( move |ty, is_struct , is_union | {
835
+ cfg. rename_struct_ty ( |ty| {
844
836
match ty {
845
837
// Just pass all these through, no need for a "struct" prefix
846
- "FILE" | "DIR" | "Dl_info" => ty. to_string ( ) ,
847
-
838
+ "FILE" | "DIR" | "Dl_info" => ty. to_string ( ) . into ( ) ,
839
+ t if t. ends_with ( "_t" ) => t. to_string ( ) . into ( ) ,
840
+ // Windows uppercase structs don't have `struct` in fr.into()ont:
841
+ t if ty. chars ( ) . next ( ) . unwrap ( ) . is_uppercase ( ) => t. to_string ( ) . into ( ) ,
842
+ "stat" => "struct __stat64" . to_string ( ) . into ( ) ,
843
+ "utimbuf" => "struct __utimbuf64" . to_string ( ) . into ( ) ,
844
+ _ => None ,
845
+ }
846
+ } ) ;
847
+ cfg. rename_type ( move |ty| {
848
+ match ty {
848
849
// FIXME(windows): these don't exist:
849
- "time64_t" => "__time64_t" . to_string ( ) ,
850
- "ssize_t" => "SSIZE_T" . to_string ( ) ,
851
-
852
- "sighandler_t" if !gnu => "_crt_signal_t" . to_string ( ) ,
853
- "sighandler_t" if gnu => "__p_sig_fn_t" . to_string ( ) ,
854
-
855
- t if is_union => format ! ( "union {t}" ) ,
856
- t if t. ends_with ( "_t" ) => t. to_string ( ) ,
850
+ "time64_t" => "__time64_t" . to_string ( ) . into ( ) ,
851
+ "ssize_t" => "SSIZE_T" . to_string ( ) . into ( ) ,
857
852
858
- // Windows uppercase structs don't have `struct` in front:
859
- t if is_struct => {
860
- if ty. chars ( ) . next ( ) . unwrap ( ) . is_uppercase ( ) {
861
- t. to_string ( )
862
- } else if t == "stat" {
863
- "struct __stat64" . to_string ( )
864
- } else if t == "utimbuf" {
865
- "struct __utimbuf64" . to_string ( )
866
- } else {
867
- // put `struct` in front of all structs:
868
- format ! ( "struct {t}" )
869
- }
870
- }
871
- t => t. to_string ( ) ,
853
+ "sighandler_t" if !gnu => "_crt_signal_t" . to_string ( ) . into ( ) ,
854
+ "sighandler_t" if gnu => "__p_sig_fn_t" . to_string ( ) . into ( ) ,
855
+ _ => None ,
872
856
}
873
857
} ) ;
874
858
875
- cfg. fn_cname ( move |name, cname| cname. unwrap_or ( name) . to_string ( ) ) ;
859
+ cfg. rename_fn ( move |func| {
860
+ func. link_name ( )
861
+ . map ( |l| l. to_string ( ) )
862
+ . or ( func. ident ( ) . to_string ( ) . into ( ) )
863
+ } ) ;
876
864
877
- cfg. skip_type ( move |name | match name {
865
+ cfg. skip_alias ( move |alias | match alias . ident ( ) {
878
866
"SSIZE_T" if !gnu => true ,
879
867
"ssize_t" if !gnu => true ,
880
868
// FIXME(windows): The size and alignment of this type are incorrect
881
869
"time_t" if gnu && i686 => true ,
882
870
_ => false ,
883
871
} ) ;
884
872
885
- cfg. skip_struct ( move |ty| {
873
+ cfg. skip_struct ( move |struct_| {
874
+ let ty = struct_. ident ( ) ;
886
875
if ty. starts_with ( "__c_anonymous_" ) {
887
876
return true ;
888
877
}
@@ -892,9 +881,10 @@ fn test_windows(target: &str) {
892
881
_ => false ,
893
882
}
894
883
} ) ;
884
+ cfg. skip_union ( move |union_| union_. ident ( ) . starts_with ( "__c_anonymous_" ) ) ;
895
885
896
- cfg. skip_const ( move |name | {
897
- match name {
886
+ cfg. skip_const ( move |constant | {
887
+ match constant . ident ( ) {
898
888
// FIXME(windows): API error:
899
889
// SIG_ERR type is "void (*)(int)", not "int"
900
890
"SIG_ERR" |
@@ -906,12 +896,9 @@ fn test_windows(target: &str) {
906
896
}
907
897
} ) ;
908
898
909
- cfg. skip_field ( move |s, field| match s {
910
- "CONTEXT" if field == "Fp" => true ,
911
- _ => false ,
912
- } ) ;
899
+ cfg. skip_struct_field ( move |s, field| s. ident ( ) == "CONTEXT" && field. ident ( ) == "Fp" ) ;
913
900
// FIXME(windows): All functions point to the wrong addresses?
914
- cfg. skip_fn_ptrcheck ( |_| true ) ;
901
+ // cfg.skip_fn_ptr_check (|_| true);
915
902
916
903
cfg. skip_signededness ( move |c| {
917
904
match c {
@@ -926,7 +913,7 @@ fn test_windows(target: &str) {
926
913
927
914
cfg. skip_fn ( |_| false ) ;
928
915
929
- cfg. generate ( src_hotfix_dir ( ) . join ( " lib.rs") , "ctest_output.rs" ) ;
916
+ ctest_next :: generate_test ( & mut cfg, "../src/ lib.rs", "ctest_output.rs" ) . unwrap ( ) ;
930
917
}
931
918
932
919
fn test_redox ( target : & str ) {
0 commit comments