1
1
//! Tests for supporting older versions of the Cargo.lock file format.
2
2
3
- #![ allow( deprecated) ]
4
-
5
3
use cargo_test_support:: compare:: assert_e2e;
6
4
use cargo_test_support:: git;
7
5
use cargo_test_support:: registry:: Package ;
@@ -236,10 +234,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
236
234
237
235
p. cargo ( "check" )
238
236
. with_status ( 101 )
239
- . with_stderr (
240
- "\
241
- [UPDATING] `[..]` index
242
- error: checksum for `bar v0.1.0` changed between lock files
237
+ . with_stderr_data ( str![ [ r#"
238
+ [UPDATING] `dummy-registry` index
239
+ [ERROR] checksum for `bar v0.1.0` changed between lock files
243
240
244
241
this could be indicative of a few possible errors:
245
242
@@ -249,8 +246,8 @@ this could be indicative of a few possible errors:
249
246
250
247
unable to verify that `bar v0.1.0` is the same as when the lockfile was generated
251
248
252
- " ,
253
- )
249
+
250
+ "# ] ] )
254
251
. run ( ) ;
255
252
}
256
253
@@ -297,25 +294,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
297
294
) ;
298
295
let p = p. build ( ) ;
299
296
300
- p. cargo ( "fetch" )
301
- . with_status ( 101 )
302
- . with_stderr (
303
- "\
304
- [UPDATING] `[..]` index
305
- error: checksum for `bar v0.1.0` was not previously calculated, but a checksum \
306
- could now be calculated
297
+ p. cargo ( "fetch" ) . with_status ( 101 ) . with_stderr_data ( str![ [ r#"
298
+ [UPDATING] `dummy-registry` index
299
+ [ERROR] checksum for `bar v0.1.0` was not previously calculated, but a checksum could now be calculated
307
300
308
301
this could be indicative of a few possible situations:
309
302
310
- * the source `[..] ` did not previously support checksums,
303
+ * the source `registry `crates-io` ` did not previously support checksums,
311
304
but was replaced with one that does
312
305
* newer Cargo implementations know how to checksum this source, but this
313
306
older implementation does not
314
307
* the lock file is corrupt
315
308
316
- " ,
317
- )
318
- . run ( ) ;
309
+
310
+ "# ] ] ) . run ( ) ;
319
311
}
320
312
321
313
// If the checksum is listed in the lock file yet we cannot calculate it (e.g.,
@@ -370,25 +362,20 @@ source = "git+{0}"
370
362
371
363
let p = p. build ( ) ;
372
364
373
- p. cargo ( "fetch" )
374
- . with_status ( 101 )
375
- . with_stderr (
376
- "\
377
- [UPDATING] git repository `[..]`
378
- error: checksum for `bar v0.1.0 ([..])` could not be calculated, but a \
379
- checksum is listed in the existing lock file[..]
365
+ p. cargo ( "fetch" ) . with_status ( 101 ) . with_stderr_data ( str![ [ r#"
366
+ [UPDATING] git repository `[ROOTURL]/bar`
367
+ [ERROR] checksum for `bar v0.1.0 ([ROOTURL]/bar)` could not be calculated, but a checksum is listed in the existing lock file
380
368
381
369
this could be indicative of a few possible situations:
382
370
383
- * the source `[..] ` supports checksums,
371
+ * the source `[ROOTURL]/bar ` supports checksums,
384
372
but was replaced with one that doesn't
385
373
* the lock file is corrupt
386
374
387
- unable to verify that `bar v0.1.0 ([..] )` is the same as when the lockfile was generated
375
+ unable to verify that `bar v0.1.0 ([ROOTURL]/bar )` is the same as when the lockfile was generated
388
376
389
- " ,
390
- )
391
- . run ( ) ;
377
+
378
+ "# ] ] ) . run ( ) ;
392
379
}
393
380
394
381
#[ cargo_test]
@@ -527,14 +514,12 @@ fn locked_correct_error() {
527
514
528
515
p. cargo ( "check --locked" )
529
516
. with_status ( 101 )
530
- . with_stderr (
531
- "\
532
- [UPDATING] `[..]` index
533
- error: the lock file [CWD]/Cargo.lock needs to be updated but --locked was passed to prevent this
534
- If you want to try to generate the lock file without accessing the network, \
535
- remove the --locked flag and use --offline instead.
536
- " ,
537
- )
517
+ . with_stderr_data ( str![ [ r#"
518
+ [UPDATING] `dummy-registry` index
519
+ [ERROR] the lock file [ROOT]/foo/Cargo.lock needs to be updated but --locked was passed to prevent this
520
+ If you want to try to generate the lock file without accessing the network, remove the --locked flag and use --offline instead.
521
+
522
+ "# ] ] )
538
523
. run ( ) ;
539
524
}
540
525
@@ -731,18 +716,13 @@ fn lock_from_the_future() {
731
716
. file ( "Cargo.lock" , "version = 10000000" )
732
717
. build ( ) ;
733
718
734
- p. cargo ( "fetch" )
735
- . with_stderr (
736
- "\
737
- error: failed to parse lock file at: [..]
719
+ p. cargo ( "fetch" ) . with_stderr_data ( str![ [ r#"
720
+ [ERROR] failed to parse lock file at: [ROOT]/foo/Cargo.lock
738
721
739
722
Caused by:
740
- lock file version `10000000` was found, but this version of Cargo does not \
741
- understand this lock file, perhaps Cargo needs to be updated?
742
- " ,
743
- )
744
- . with_status ( 101 )
745
- . run ( ) ;
723
+ lock file version `10000000` was found, but this version of Cargo does not understand this lock file, perhaps Cargo needs to be updated?
724
+
725
+ "# ] ] ) . with_status ( 101 ) . run ( ) ;
746
726
}
747
727
748
728
#[ cargo_test]
@@ -904,16 +884,15 @@ dependencies = [
904
884
. build ( ) ;
905
885
p. cargo ( "check" )
906
886
. with_status ( 101 )
907
- . with_stderr (
908
- "\
909
- [..]
910
- [ERROR] failed to select a version for the requirement `bar = \" *\" ` (locked to 0.1.0)
887
+ . with_stderr_data ( str![ [ r#"
888
+ [UPDATING] `dummy-registry` index
889
+ [ERROR] failed to select a version for the requirement `bar = "*"` (locked to 0.1.0)
911
890
candidate versions found which didn't match: 0.0.1
912
891
location searched: `dummy-registry` index (which is replacing registry `crates-io`)
913
- required by package `test v0.0.0 ([..] )`
892
+ required by package `test v0.0.0 ([ROOT]/foo )`
914
893
perhaps a crate was updated and forgotten to be re-vendored?
915
- " ,
916
- )
894
+
895
+ "# ] ] )
917
896
. run ( ) ;
918
897
}
919
898
@@ -935,31 +914,25 @@ fn next_version_is_always_unstable() {
935
914
. file ( "Cargo.lock" , "version = 5" )
936
915
. build ( ) ;
937
916
938
- p. cargo ( "fetch" )
939
- . with_status ( 101 )
940
- . with_stderr (
941
- "\
942
- error: failed to parse lock file at: [CWD]/Cargo.lock
917
+ p. cargo ( "fetch" ) . with_status ( 101 ) . with_stderr_data ( str![ [ r#"
918
+ [ERROR] failed to parse lock file at: [ROOT]/foo/Cargo.lock
943
919
944
920
Caused by:
945
- lock file version `5` was found, but this version of Cargo does not \
946
- understand this lock file, perhaps Cargo needs to be updated?
947
- " ,
948
- )
949
- . run ( ) ;
921
+ lock file version `5` was found, but this version of Cargo does not understand this lock file, perhaps Cargo needs to be updated?
922
+
923
+ "# ] ] ) . run ( ) ;
950
924
951
925
// On nightly, let the user know about the `-Z` flag.
952
926
p. cargo ( "fetch" )
953
927
. masquerade_as_nightly_cargo ( & [ "-Znext-lockfile-bump" ] )
954
928
. with_status ( 101 )
955
- . with_stderr (
956
- "\
957
- error: failed to parse lock file at: [CWD]/Cargo.lock
929
+ . with_stderr_data ( str![ [ r#"
930
+ [ERROR] failed to parse lock file at: [ROOT]/foo/Cargo.lock
958
931
959
932
Caused by:
960
933
lock file version `5` requires `-Znext-lockfile-bump`
961
- " ,
962
- )
934
+
935
+ "# ] ] )
963
936
. run ( ) ;
964
937
}
965
938
@@ -1062,15 +1035,15 @@ dependencies = [
1062
1035
. build ( ) ;
1063
1036
1064
1037
p. cargo ( "check" )
1065
- . with_stderr ( format ! (
1038
+ . with_stderr_data ( format ! (
1066
1039
"\
1067
- [UPDATING] git repository `{url} `
1040
+ [UPDATING] git repository `[ROOTURL]/dep1 `
1068
1041
[LOCKING] 2 packages to latest compatible versions
1069
- [ADDING] dep1 v0.5.0 ({url} ?{ref_kind}={git_ref}#[..])
1070
- [ADDING] foo v0.0.1 ([CWD] )
1071
- [CHECKING] dep1 v0.5.0 ({url} ?{ref_kind}={git_ref}#[..])
1072
- [CHECKING] foo v0.0.1 ([CWD] )
1073
- [FINISHED] `dev` profile [..]
1042
+ [ADDING] dep1 v0.5.0 ([ROOTURL]/dep1 ?{ref_kind}={git_ref}#[..])
1043
+ [ADDING] foo v0.0.1 ([ROOT]/foo )
1044
+ [CHECKING] dep1 v0.5.0 ([ROOTURL]/dep1 ?{ref_kind}={git_ref}#[..])
1045
+ [CHECKING] foo v0.0.1 ([ROOT]/foo )
1046
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
1074
1047
"
1075
1048
) )
1076
1049
. run ( ) ;
@@ -1082,10 +1055,10 @@ dependencies = [
1082
1055
// was URL-encoded. Therefore Cargo thinks they are from different source
1083
1056
// and clones the repository again.
1084
1057
p. cargo ( "check" )
1085
- . with_stderr ( format ! (
1058
+ . with_stderr_data ( format ! (
1086
1059
"\
1087
- [UPDATING] git repository `{url} `
1088
- [FINISHED] `dev` profile [..]
1060
+ [UPDATING] git repository `[ROOTURL]/dep1 `
1061
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
1089
1062
"
1090
1063
) )
1091
1064
. run ( ) ;
@@ -1158,15 +1131,15 @@ dependencies = [
1158
1131
. build ( ) ;
1159
1132
1160
1133
p. cargo ( "check" )
1161
- . with_stderr ( format ! (
1134
+ . with_stderr_data ( format ! (
1162
1135
"\
1163
- [UPDATING] git repository `{url} `
1136
+ [UPDATING] git repository `[ROOTURL]/dep1 `
1164
1137
[LOCKING] 2 packages to latest compatible versions
1165
- [ADDING] dep1 v0.5.0 ({url} ?{ref_kind}={git_ref}#[..])
1166
- [ADDING] foo v0.0.1 ([CWD] )
1167
- [CHECKING] dep1 v0.5.0 ({url} ?{ref_kind}={git_ref}#[..])
1168
- [CHECKING] foo v0.0.1 ([CWD] )
1169
- [FINISHED] `dev` profile [..]
1138
+ [ADDING] dep1 v0.5.0 ([ROOTURL]/dep1 ?{ref_kind}={git_ref}#[..])
1139
+ [ADDING] foo v0.0.1 ([ROOT]/foo )
1140
+ [CHECKING] dep1 v0.5.0 ([ROOTURL]/dep1 ?{ref_kind}={git_ref}#[..])
1141
+ [CHECKING] foo v0.0.1 ([ROOT]/foo )
1142
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
1170
1143
"
1171
1144
) )
1172
1145
. run ( ) ;
@@ -1177,7 +1150,11 @@ dependencies = [
1177
1150
// Unlike v3_and_git_url_encoded, v4 encodes URL parameters so no git
1178
1151
// repository re-clone happen.
1179
1152
p. cargo ( "check" )
1180
- . with_stderr ( "[FINISHED] `dev` profile [..]" )
1153
+ . with_stderr_data (
1154
+ "\
1155
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
1156
+ " ,
1157
+ )
1181
1158
. run ( ) ;
1182
1159
}
1183
1160
0 commit comments