@@ -231,31 +231,10 @@ mod tests {
231
231
use super :: * ;
232
232
use std:: io:: Cursor ;
233
233
234
- #[ test]
235
- fn test_from_read_buffer_to_env_and_flags ( ) {
236
- let buff = Cursor :: new (
237
- "
238
- cargo::rustc-link-lib=sdfsdf
239
- cargo::rustc-env=FOO=BAR
240
- cargo::rustc-link-search=/some/absolute/path/bleh
241
- cargo::rustc-env=BAR=FOO
242
- cargo::rustc-flags=-Lblah
243
- cargo::rerun-if-changed=ignored
244
- cargo::rustc-cfg=feature=awesome
245
- cargo::version=123
246
- cargo::version_number=1010107f
247
- cargo::include_path=/some/absolute/path/include
248
- cargo::rustc-env=SOME_PATH=/some/absolute/path/beep
249
- cargo::rustc-link-arg=-weak_framework
250
- cargo::rustc-link-arg=Metal
251
- cargo::rustc-env=no_trailing_newline=true
252
- non-cargo-prefixes::are-ignored=true
253
- non-assignment-instructions-are-ignored
254
- cargo:rustc-env=old_cargo_colon_prefix_works=true" ,
255
- ) ;
234
+ fn from_read_buffer_to_env_and_flags_test_impl ( buff : Cursor < & str > ) {
256
235
let reader = BufReader :: new ( buff) ;
257
236
let result = BuildScriptOutput :: outputs_from_reader ( reader) ;
258
- assert_eq ! ( result. len( ) , 14 ) ;
237
+ assert_eq ! ( result. len( ) , 13 ) ;
259
238
assert_eq ! ( result[ 0 ] , BuildScriptOutput :: LinkLib ( "sdfsdf" . to_owned( ) ) ) ;
260
239
assert_eq ! ( result[ 1 ] , BuildScriptOutput :: Env ( "FOO=BAR" . to_owned( ) ) ) ;
261
240
assert_eq ! (
@@ -289,17 +268,13 @@ cargo:rustc-env=old_cargo_colon_prefix_works=true",
289
268
result[ 12 ] ,
290
269
BuildScriptOutput :: Env ( "no_trailing_newline=true" . to_owned( ) )
291
270
) ;
292
- assert_eq ! (
293
- result[ 13 ] ,
294
- BuildScriptOutput :: Env ( "old_cargo_colon_prefix_works=true" . to_owned( ) )
295
- ) ;
296
271
assert_eq ! (
297
272
BuildScriptOutput :: outputs_to_dep_env( & result, "ssh2" , "/some/absolute/path" ) ,
298
273
"DEP_SSH2_VERSION=123\n DEP_SSH2_VERSION_NUMBER=1010107f\n DEP_SSH2_INCLUDE_PATH=${pwd}/include" . to_owned( )
299
274
) ;
300
275
assert_eq ! (
301
276
BuildScriptOutput :: outputs_to_env( & result, "/some/absolute/path" ) ,
302
- "FOO=BAR\n BAR=FOO\n SOME_PATH=${pwd}/beep\n no_trailing_newline=true\n old_cargo_colon_prefix_works=true " . to_owned( )
277
+ "FOO=BAR\n BAR=FOO\n SOME_PATH=${pwd}/beep\n no_trailing_newline=true" . to_owned( )
303
278
) ;
304
279
assert_eq ! (
305
280
BuildScriptOutput :: outputs_to_flags( & result, "/some/absolute/path" ) ,
@@ -315,13 +290,81 @@ cargo:rustc-env=old_cargo_colon_prefix_works=true",
315
290
) ;
316
291
}
317
292
293
+ #[ test]
294
+ fn test_from_read_buffer_to_env_and_flags ( ) {
295
+ let buff = Cursor :: new (
296
+ "
297
+ cargo::rustc-link-lib=sdfsdf
298
+ cargo::rustc-env=FOO=BAR
299
+ cargo::rustc-link-search=/some/absolute/path/bleh
300
+ cargo::rustc-env=BAR=FOO
301
+ cargo::rustc-flags=-Lblah
302
+ cargo::rerun-if-changed=ignored
303
+ cargo::rustc-cfg=feature=awesome
304
+ cargo::version=123
305
+ cargo::version_number=1010107f
306
+ cargo::include_path=/some/absolute/path/include
307
+ cargo::rustc-env=SOME_PATH=/some/absolute/path/beep
308
+ cargo::rustc-link-arg=-weak_framework
309
+ cargo::rustc-link-arg=Metal
310
+ cargo::rustc-env=no_trailing_newline=true
311
+ non-cargo-prefixes::are-ignored=true
312
+ non-assignment-instructions-are-ignored" ,
313
+ ) ;
314
+ from_read_buffer_to_env_and_flags_test_impl ( buff) ;
315
+ }
316
+
317
+ /// Demonstrate that the old style single colon flags are all parsable
318
+ #[ test]
319
+ fn test_legacy_from_read_buffer_to_env_and_flags ( ) {
320
+ let buff = Cursor :: new (
321
+ "
322
+ cargo:rustc-link-lib=sdfsdf
323
+ cargo:rustc-env=FOO=BAR
324
+ cargo:rustc-link-search=/some/absolute/path/bleh
325
+ cargo:rustc-env=BAR=FOO
326
+ cargo:rustc-flags=-Lblah
327
+ cargo:rerun-if-changed=ignored
328
+ cargo:rustc-cfg=feature=awesome
329
+ cargo:version=123
330
+ cargo:version_number=1010107f
331
+ cargo:include_path=/some/absolute/path/include
332
+ cargo:rustc-env=SOME_PATH=/some/absolute/path/beep
333
+ cargo:rustc-link-arg=-weak_framework
334
+ cargo:rustc-link-arg=Metal
335
+ cargo:rustc-env=no_trailing_newline=true
336
+ non-cargo-prefixes:are-ignored=true
337
+ non-assignment-instructions-are-ignored" ,
338
+ ) ;
339
+ from_read_buffer_to_env_and_flags_test_impl ( buff) ;
340
+ }
341
+
318
342
#[ test]
319
343
fn invalid_utf8 ( ) {
320
344
let buff = Cursor :: new (
321
345
b"
322
346
cargo::rustc-env=valid1=1
323
347
cargo::rustc-env=invalid=\xc3 \x28
324
348
cargo::rustc-env=valid2=2
349
+ " ,
350
+ ) ;
351
+ let reader = BufReader :: new ( buff) ;
352
+ let result = BuildScriptOutput :: outputs_from_reader ( reader) ;
353
+ assert_eq ! ( result. len( ) , 2 ) ;
354
+ assert_eq ! (
355
+ & BuildScriptOutput :: outputs_to_env( & result, "/some/absolute/path" ) ,
356
+ "valid1=1\n valid2=2"
357
+ ) ;
358
+ }
359
+
360
+ /// Demonstrate that the old style single colon flags are all parsable
361
+ #[ test]
362
+ fn invalid_utf8_legacy ( ) {
363
+ let buff = Cursor :: new (
364
+ b"
365
+ cargo:rustc-env=valid1=1
366
+ cargo:rustc-env=invalid=\xc3 \x28
367
+ cargo:rustc-env=valid2=2
325
368
" ,
326
369
) ;
327
370
let reader = BufReader :: new ( buff) ;
0 commit comments