File tree Expand file tree Collapse file tree 2 files changed +51
-0
lines changed Expand file tree Collapse file tree 2 files changed +51
-0
lines changed Original file line number Diff line number Diff line change @@ -104,6 +104,32 @@ fn list_command_looks_at_path() {
104
104
) ;
105
105
}
106
106
107
+ #[ cfg( windows) ]
108
+ #[ cargo_test]
109
+ fn list_command_looks_at_path_case_mismatch ( ) {
110
+ let proj = project ( )
111
+ . executable ( Path :: new ( "path-test" ) . join ( "cargo-1" ) , "" )
112
+ . build ( ) ;
113
+
114
+ let mut path = path ( ) ;
115
+ path. push ( proj. root ( ) . join ( "path-test" ) ) ;
116
+ let path = env:: join_paths ( path. iter ( ) ) . unwrap ( ) ;
117
+
118
+ // See issue #11814: Environment variable names are case-insensitive on Windows.
119
+ // We need to check that having "Path" instead of "PATH" is okay.
120
+ let output = cargo_process ( "-v --list" )
121
+ . env ( "Path" , & path)
122
+ . env_remove ( "PATH" )
123
+ . exec_with_output ( )
124
+ . unwrap ( ) ;
125
+ let output = str:: from_utf8 ( & output. stdout ) . unwrap ( ) ;
126
+ assert ! (
127
+ output. contains( "\n 1 " ) ,
128
+ "missing 1: {}" ,
129
+ output
130
+ ) ;
131
+ }
132
+
107
133
#[ cargo_test]
108
134
fn list_command_handles_known_external_commands ( ) {
109
135
let p = project ( )
Original file line number Diff line number Diff line change @@ -211,6 +211,31 @@ f1 = 123
211
211
assert_eq ! ( s, S { f1: Some ( 456 ) } ) ;
212
212
}
213
213
214
+ #[ cfg( windows) ]
215
+ #[ cargo_test]
216
+ fn environment_variable_casing ( ) {
217
+ // Issue #11814: Environment variable names are case-insensitive on Windows.
218
+ let config = ConfigBuilder :: new ( )
219
+ . env ( "Path" , "abc" )
220
+ . env ( "Two-Words" , "abc" )
221
+ . env ( "two_words" , "def" )
222
+ . build ( ) ;
223
+
224
+ let var = config. get_env ( "PATH" ) . unwrap ( ) ;
225
+ assert_eq ! ( var, String :: from( "abc" ) ) ;
226
+
227
+ let var = config. get_env ( "path" ) . unwrap ( ) ;
228
+ assert_eq ! ( var, String :: from( "abc" ) ) ;
229
+
230
+ let var = config. get_env ( "TWO-WORDS" ) . unwrap ( ) ;
231
+ assert_eq ! ( var, String :: from( "abc" ) ) ;
232
+
233
+ // Make sure that we can still distinguish between dashes and underscores
234
+ // in variable names.
235
+ let var = config. get_env ( "Two_Words" ) . unwrap ( ) ;
236
+ assert_eq ! ( var, String :: from( "def" ) ) ;
237
+ }
238
+
214
239
#[ cargo_test]
215
240
fn config_works_with_extension ( ) {
216
241
write_config_toml (
You can’t perform that action at this time.
0 commit comments