@@ -872,6 +872,7 @@ impl<'a> Drop for Env<'a> {
872
872
#[ cfg( test) ]
873
873
mod tests {
874
874
use super :: * ;
875
+ use std:: ffi:: OsStr ;
875
876
876
877
#[ test]
877
878
fn parse_version ( ) {
@@ -932,4 +933,44 @@ mod tests {
932
933
assert_eq ! ( lines, Vec :: <& str >:: new( ) , "should be no config variables from files" ) ;
933
934
assert_eq ! ( status, 0 , "reading the config should succeed" ) ;
934
935
}
936
+
937
+ #[ test]
938
+ fn configure_command_msys ( ) {
939
+ let temp = tempfile:: TempDir :: new ( ) . expect ( "can create temp dir" ) ;
940
+ let mut cmd = std:: process:: Command :: new ( "not-actually-run" ) ;
941
+
942
+ let msys_option = configure_command ( & mut cmd, & [ ] , temp. path ( ) )
943
+ . get_envs ( )
944
+ . find ( |( k, _) | * k == OsStr :: new ( "MSYS" ) )
945
+ . expect ( "should customize MSYS variable" )
946
+ . 1
947
+ . expect ( "should set, not unset, MSYS variable" )
948
+ . to_str ( )
949
+ . expect ( "valid UTF-8" )
950
+ . trim_matches ( ' ' ) ;
951
+
952
+ assert_eq ! ( msys_option, "winsymlinks:nativestrict" ) ;
953
+ }
954
+
955
+ #[ test]
956
+ fn configure_command_msys_extends ( ) {
957
+ let old_msys = r"error_start:C:\gdb.exe" ;
958
+ let temp = tempfile:: TempDir :: new ( ) . expect ( "can create temp dir" ) ;
959
+ let mut cmd = std:: process:: Command :: new ( "not-actually-run" ) ;
960
+ cmd. env ( "MSYS" , old_msys) ;
961
+
962
+ let msys_options = configure_command ( & mut cmd, & [ ] , temp. path ( ) )
963
+ . get_envs ( )
964
+ . find ( |( k, _) | * k == OsStr :: new ( "MSYS" ) )
965
+ . expect ( "should customize MSYS variable" )
966
+ . 1
967
+ . expect ( "should set, not unset, MSYS variable" )
968
+ . to_str ( )
969
+ . expect ( "valid UTF-8" )
970
+ . split ( ' ' ) // Just spaces, not arbitrary whitespace.
971
+ . filter ( |s| !s. is_empty ( ) )
972
+ . collect :: < Vec < _ > > ( ) ;
973
+
974
+ assert_eq ! ( msys_options, vec![ old_msys, "winsymlinks:nativestrict" ] ) ;
975
+ }
935
976
}
0 commit comments