@@ -1027,12 +1027,31 @@ impl<'test> TestCx<'test> {
1027
1027
}
1028
1028
1029
1029
fn set_revision_flags ( & self , cmd : & mut Command ) {
1030
+ // Normalize revisions to be lowercase and replace `-`s with `_`s.
1031
+ // Otherwise the `--cfg` flag is not valid.
1032
+ let normalize_revision = |revision : & str | revision. to_lowercase ( ) . replace ( "-" , "_" ) ;
1033
+
1030
1034
if let Some ( revision) = self . revision {
1031
- // Normalize revisions to be lowercase and replace `-`s with `_`s.
1032
- // Otherwise the `--cfg` flag is not valid.
1033
- let normalized_revision = revision. to_lowercase ( ) . replace ( "-" , "_" ) ;
1035
+ let normalized_revision = normalize_revision ( revision) ;
1034
1036
cmd. args ( & [ "--cfg" , & normalized_revision] ) ;
1035
1037
}
1038
+
1039
+ if !self . props . no_auto_check_cfg {
1040
+ let mut check_cfg = String :: with_capacity ( 25 ) ;
1041
+
1042
+ // Generate `cfg(FALSE, REV1, ..., REVN)` (for all possible revisions)
1043
+ //
1044
+ // For compatibility reason we consider the `FALSE` cfg to be expected
1045
+ // since it is extensively used in the testsuite.
1046
+ check_cfg. push_str ( "cfg(FALSE" ) ;
1047
+ for revision in & self . props . revisions {
1048
+ check_cfg. push_str ( "," ) ;
1049
+ check_cfg. push_str ( & normalize_revision ( & revision) ) ;
1050
+ }
1051
+ check_cfg. push_str ( ")" ) ;
1052
+
1053
+ cmd. args ( & [ "--check-cfg" , & check_cfg] ) ;
1054
+ }
1036
1055
}
1037
1056
1038
1057
fn typecheck_source ( & self , src : String ) -> ProcRes {
0 commit comments