@@ -65,7 +65,10 @@ fn do_ctest() {
65
65
t if t. contains ( "solaris" ) => test_solarish ( t) ,
66
66
t if t. contains ( "illumos" ) => test_solarish ( t) ,
67
67
t if t. contains ( "wasi" ) => test_wasi ( t) ,
68
- t if t. contains ( "windows" ) => test_windows ( t) ,
68
+ t if t. contains ( "windows" ) => {
69
+ test_windows_next ( t) ;
70
+ test_windows ( t) ;
71
+ }
69
72
t if t. contains ( "vxworks" ) => test_vxworks ( t) ,
70
73
t if t. contains ( "nto-qnx" ) => test_neutrino ( t) ,
71
74
t if t. contains ( "aix" ) => return test_aix ( t) ,
@@ -77,6 +80,10 @@ fn ctest_cfg() -> ctest::TestGenerator {
77
80
ctest:: TestGenerator :: new ( )
78
81
}
79
82
83
+ fn ctest_next_cfg ( ) -> ctest_next:: TestGenerator {
84
+ ctest_next:: TestGenerator :: new ( )
85
+ }
86
+
80
87
fn do_semver ( ) {
81
88
let mut out = PathBuf :: from ( env:: var ( "OUT_DIR" ) . unwrap ( ) ) ;
82
89
out. push ( "semver.rs" ) ;
@@ -164,6 +171,13 @@ fn main() {
164
171
let re = regex:: bytes:: Regex :: new ( r"(?-u:\b)crate::" ) . unwrap ( ) ;
165
172
copy_dir_hotfix ( Path :: new ( "../src" ) , & hotfix_dir, & re, b"::" ) ;
166
173
174
+ // FIXME(ctest): Only needed until ctest-next supports all tests.
175
+ std:: fs:: write (
176
+ format ! ( "{}/main_next.rs" , std:: env:: var( "OUT_DIR" ) . unwrap( ) ) ,
177
+ "\n fn main() { println!(\" test result: ok\" ); }\n " ,
178
+ )
179
+ . unwrap_or_default ( ) ;
180
+
167
181
do_cc ( ) ;
168
182
do_ctest ( ) ;
169
183
do_semver ( ) ;
@@ -945,6 +959,123 @@ fn test_windows(target: &str) {
945
959
cfg. generate ( src_hotfix_dir ( ) . join ( "lib.rs" ) , "main.rs" ) ;
946
960
}
947
961
962
+ fn test_windows_next ( target : & str ) {
963
+ assert ! ( target. contains( "windows" ) ) ;
964
+ let gnu = target. contains ( "gnu" ) ;
965
+ let i686 = target. contains ( "i686" ) ;
966
+
967
+ let mut cfg = ctest_next_cfg ( ) ;
968
+ if target. contains ( "msvc" ) {
969
+ cfg. flag ( "/wd4324" ) ;
970
+ }
971
+ cfg. define ( "_WIN32_WINNT" , Some ( "0x8000" ) ) ;
972
+
973
+ headers ! { cfg:
974
+ "direct.h" ,
975
+ "errno.h" ,
976
+ "fcntl.h" ,
977
+ "io.h" ,
978
+ "limits.h" ,
979
+ "locale.h" ,
980
+ "process.h" ,
981
+ "signal.h" ,
982
+ "stddef.h" ,
983
+ "stdint.h" ,
984
+ "stdio.h" ,
985
+ "stdlib.h" ,
986
+ "sys/stat.h" ,
987
+ "sys/types.h" ,
988
+ "sys/utime.h" ,
989
+ "time.h" ,
990
+ "wchar.h" ,
991
+ [ gnu] : "ws2tcpip.h" ,
992
+ [ !gnu] : "Winsock2.h" ,
993
+ }
994
+
995
+ cfg. rename_struct_ty ( |ty| {
996
+ match ty {
997
+ // Just pass all these through, no need for a "struct" prefix
998
+ "FILE" | "DIR" | "Dl_info" => ty. to_string ( ) . into ( ) ,
999
+ t if t. ends_with ( "_t" ) => t. to_string ( ) . into ( ) ,
1000
+ // Windows uppercase structs don't have `struct` in fr.into()ont:
1001
+ t if ty. chars ( ) . next ( ) . unwrap ( ) . is_uppercase ( ) => t. to_string ( ) . into ( ) ,
1002
+ "stat" => "struct __stat64" . to_string ( ) . into ( ) ,
1003
+ "utimbuf" => "struct __utimbuf64" . to_string ( ) . into ( ) ,
1004
+ _ => None ,
1005
+ }
1006
+ } ) ;
1007
+ cfg. rename_type ( move |ty| {
1008
+ match ty {
1009
+ // FIXME(windows): these don't exist:
1010
+ "time64_t" => "__time64_t" . to_string ( ) . into ( ) ,
1011
+ "ssize_t" => "SSIZE_T" . to_string ( ) . into ( ) ,
1012
+
1013
+ "sighandler_t" if !gnu => "_crt_signal_t" . to_string ( ) . into ( ) ,
1014
+ "sighandler_t" if gnu => "__p_sig_fn_t" . to_string ( ) . into ( ) ,
1015
+ _ => None ,
1016
+ }
1017
+ } ) ;
1018
+
1019
+ cfg. rename_fn ( move |func| {
1020
+ func. link_name ( )
1021
+ . map ( |l| l. to_string ( ) )
1022
+ . or ( func. ident ( ) . to_string ( ) . into ( ) )
1023
+ } ) ;
1024
+
1025
+ cfg. skip_alias ( move |alias| match alias. ident ( ) {
1026
+ "SSIZE_T" if !gnu => true ,
1027
+ "ssize_t" if !gnu => true ,
1028
+ // FIXME(windows): The size and alignment of this type are incorrect
1029
+ "time_t" if gnu && i686 => true ,
1030
+ _ => false ,
1031
+ } ) ;
1032
+
1033
+ cfg. skip_struct ( move |struct_| {
1034
+ let ty = struct_. ident ( ) ;
1035
+ if ty. starts_with ( "__c_anonymous_" ) {
1036
+ return true ;
1037
+ }
1038
+ match ty {
1039
+ // FIXME(windows): The size and alignment of this struct are incorrect
1040
+ "timespec" if gnu && i686 => true ,
1041
+ _ => false ,
1042
+ }
1043
+ } ) ;
1044
+ cfg. skip_union ( move |union_| union_. ident ( ) . starts_with ( "__c_anonymous_" ) ) ;
1045
+
1046
+ cfg. skip_const ( move |constant| {
1047
+ match constant. ident ( ) {
1048
+ // FIXME(windows): API error:
1049
+ // SIG_ERR type is "void (*)(int)", not "int"
1050
+ "SIG_ERR" |
1051
+ // Similar for SIG_DFL/IGN/GET/SGE/ACK
1052
+ "SIG_DFL" | "SIG_IGN" | "SIG_GET" | "SIG_SGE" | "SIG_ACK" => true ,
1053
+ // FIXME(windows): newer windows-gnu environment on CI?
1054
+ "_O_OBTAIN_DIR" if gnu => true ,
1055
+ _ => false ,
1056
+ }
1057
+ } ) ;
1058
+
1059
+ cfg. skip_struct_field ( move |s, field| s. ident ( ) == "CONTEXT" && field. ident ( ) == "Fp" ) ;
1060
+ // FIXME(windows): All functions point to the wrong addresses?
1061
+ // cfg.skip_fn_ptr_check(|_| true);
1062
+
1063
+ cfg. skip_signededness ( move |c| {
1064
+ match c {
1065
+ // windows-isms
1066
+ n if n. starts_with ( "P" ) => true ,
1067
+ n if n. starts_with ( "H" ) => true ,
1068
+ n if n. starts_with ( "LP" ) => true ,
1069
+ "sighandler_t" if gnu => true ,
1070
+ _ => false ,
1071
+ }
1072
+ } ) ;
1073
+
1074
+ cfg. skip_fn ( |_| false ) ;
1075
+
1076
+ ctest_next:: generate_test ( & mut cfg, "../src/lib.rs" , "main_next.rs" ) . unwrap ( ) ;
1077
+ }
1078
+
948
1079
fn test_redox ( target : & str ) {
949
1080
assert ! ( target. contains( "redox" ) ) ;
950
1081
0 commit comments