@@ -50,7 +50,12 @@ mod locations {
50
50
}
51
51
52
52
#[ test]
53
- fn locations_under_program_files_ordinary ( ) {
53
+ fn locations_under_program_files_no_vars ( ) {
54
+ assert_eq ! ( locations_from!( ) , Vec :: <PathBuf >:: new( ) ) ;
55
+ }
56
+
57
+ #[ test]
58
+ fn locations_under_program_files_ordinary_values_current_var_only ( ) {
54
59
assert_eq ! (
55
60
locations_from!(
56
61
"ProgramFiles" => r"C:\Program Files" ,
@@ -64,6 +69,10 @@ mod locations {
64
69
pathbuf_vec![ r"C:\Program Files\Git\mingw32\bin" ]
65
70
} ,
66
71
) ;
72
+ }
73
+
74
+ #[ test]
75
+ fn locations_under_program_files_ordinary_values_all_vars ( ) {
67
76
assert_eq ! (
68
77
locations_from!(
69
78
"ProgramFiles" => {
@@ -82,11 +91,10 @@ mod locations {
82
91
r"C:\Program Files (x86)\Git\mingw32\bin" ,
83
92
] ,
84
93
) ;
85
- assert_eq ! ( locations_from!( ) , Vec :: <PathBuf >:: new( ) ) ;
86
94
}
87
95
88
96
#[ test]
89
- fn locations_under_program_files_strange ( ) {
97
+ fn locations_under_program_files_strange_values_all_vars_distinct ( ) {
90
98
assert_eq ! (
91
99
locations_from!(
92
100
"ProgramFiles" => r"X:\cur\rent" ,
@@ -110,12 +118,20 @@ mod locations {
110
118
]
111
119
} ,
112
120
) ;
121
+ }
122
+
123
+ #[ test]
124
+ fn locations_under_program_files_strange_values_64bit_var_only ( ) {
113
125
assert_eq ! (
114
126
locations_from!(
115
127
"ProgramW6432" => r"Z:\wi\de" ,
116
128
) ,
117
129
pathbuf_vec![ r"Z:\wi\de\Git\clangarm64\bin" , r"Z:\wi\de\Git\mingw64\bin" ] ,
118
130
) ;
131
+ }
132
+
133
+ #[ test]
134
+ fn locations_under_program_files_strange_values_all_vars_path_cruft ( ) {
119
135
assert_eq ! (
120
136
locations_from!(
121
137
"ProgramFiles" => r"Z:/wi//de/" ,
@@ -137,6 +153,10 @@ mod locations {
137
153
]
138
154
} ,
139
155
) ;
156
+ }
157
+
158
+ #[ test]
159
+ fn locations_under_program_files_strange_values_some_relative ( ) {
140
160
assert_eq ! (
141
161
locations_from!(
142
162
"ProgramFiles" => r"foo\bar" ,
@@ -161,7 +181,11 @@ mod locations {
161
181
// is for the test suite, and doing it this way allows problems to be caught earlier if
162
182
// a change made on a 64-bit development machine breaks the IsWow64Process() call.
163
183
let mut wow64process = BOOL :: default ( ) ;
164
- unsafe { IsWow64Process ( GetCurrentProcess ( ) , & mut wow64process) ? } ;
184
+ unsafe {
185
+ // SAFETY: `GetCurrentProcess` always succeeds, and the handle it returns is a
186
+ // valid process handle to pass to `IsWow64Process`.
187
+ IsWow64Process ( GetCurrentProcess ( ) , & mut wow64process) ?;
188
+ }
165
189
166
190
let platform_bitness = if wow64process. as_bool ( ) {
167
191
Self :: Is32on64
@@ -181,27 +205,29 @@ mod locations {
181
205
Some ( folded_text. ends_with ( & folded_pattern) )
182
206
}
183
207
184
- /// The common global program files paths on this system, by process and system architecture.
208
+ /// The most common global program files paths on this system, by process and system architecture.
209
+ ///
210
+ /// This omits the 32-bit ARM program files directory, as Git for Windows is never installed there.
185
211
#[ derive( Clone , Debug ) ]
186
212
struct ProgramFilesPaths {
187
213
/// The program files directory used for whatever architecture this program was built for.
188
214
current : PathBuf ,
189
215
190
- /// The x86 program files directory regardless of the architecture of the program.
216
+ /// The 32-bit x86 program files directory regardless of the architecture of the program.
191
217
///
192
218
/// If Rust gains Windows targets like ARMv7 where this is unavailable, this could fail.
193
219
x86 : PathBuf ,
194
220
195
221
/// The 64-bit program files directory if there is one.
196
222
///
197
- /// This is present on x64 and also ARM64 systems. On an ARM64 system, ARM64 and AMD64
198
- /// programs use the same program files directory while 32-bit x86 and ARM programs use
199
- /// two others. Only a 32-bit system has no 64-bit program files directory.
223
+ /// This is present on x64 (AMD64) and also ARM64 systems. On an ARM64 system, ARM64 and
224
+ /// AMD64 programs use the same program files directory while 32-bit x86 and 32-bit ARM
225
+ /// programs use two others. Only a 32-bit system has no 64-bit program files directory.
200
226
maybe_64bit : Option < PathBuf > ,
201
227
}
202
228
203
229
impl ProgramFilesPaths {
204
- /// Get the three common kinds of global program files paths without environment variables.
230
+ /// Get the three most common kinds of global program files paths without environment variables.
205
231
///
206
232
/// The idea here is to obtain this information, which the `alternative_locations()` unit
207
233
/// test uses to learn the expected alternative locations, without duplicating *any* of the
0 commit comments