@@ -1923,8 +1923,7 @@ fn update_breaking() {
1923
1923
1924
1924
[workspace.dependencies]
1925
1925
ws = "2.0" # This line gets partially rewritten
1926
-
1927
- "# ] ] ,
1926
+ "# ] ] ,
1928
1927
) ;
1929
1928
1930
1929
let foo_manifest = p. read_file ( "foo/Cargo.toml" ) ;
@@ -2014,12 +2013,12 @@ fn update_breaking_specific_packages() {
2014
2013
. file (
2015
2014
"Cargo.toml" ,
2016
2015
r#"
2017
- [workspace]
2018
- members = ["foo", "bar"]
2016
+ [workspace]
2017
+ members = ["foo", "bar"]
2019
2018
2020
- [workspace.dependencies]
2021
- ws = "1.0"
2022
- "# ,
2019
+ [workspace.dependencies]
2020
+ ws = "1.0"
2021
+ "# ,
2023
2022
)
2024
2023
. file (
2025
2024
"foo/Cargo.toml" ,
@@ -2050,7 +2049,7 @@ fn update_breaking_specific_packages() {
2050
2049
just-bar = "1.0"
2051
2050
shared = "1.0"
2052
2051
ws.workspace = true
2053
- "# ,
2052
+ "# ,
2054
2053
)
2055
2054
. file ( "bar/src/lib.rs" , "" )
2056
2055
. build ( ) ;
@@ -2096,3 +2095,353 @@ fn update_breaking_specific_packages() {
2096
2095
)
2097
2096
. run ( ) ;
2098
2097
}
2098
+
2099
+ #[ cargo_test]
2100
+ fn update_breaking_specific_packages_that_wont_update ( ) {
2101
+ Package :: new ( "compatible" , "1.0.0" ) . publish ( ) ;
2102
+ Package :: new ( "renamed-from" , "1.0.0" ) . publish ( ) ;
2103
+ Package :: new ( "non-semver" , "1.0.0" ) . publish ( ) ;
2104
+ Package :: new ( "bar" , "1.0.0" )
2105
+ . add_dep ( Dependency :: new ( "transitive-compatible" , "1.0.0" ) . build ( ) )
2106
+ . add_dep ( Dependency :: new ( "transitive-incompatible" , "1.0.0" ) . build ( ) )
2107
+ . publish ( ) ;
2108
+ Package :: new ( "transitive-compatible" , "1.0.0" ) . publish ( ) ;
2109
+ Package :: new ( "transitive-incompatible" , "1.0.0" ) . publish ( ) ;
2110
+
2111
+ let crate_manifest = r#"
2112
+ # Check if formatting is preserved
2113
+
2114
+ [package]
2115
+ name = "foo"
2116
+ version = "0.0.1"
2117
+ edition = "2015"
2118
+ authors = []
2119
+
2120
+ [dependencies]
2121
+ compatible = "1.0" # Comment
2122
+ renamed-to = { package = "renamed-from", version = "1.0" } # Comment
2123
+ non-semver = "~1.0" # Comment
2124
+ bar = "1.0" # Comment
2125
+ "# ;
2126
+
2127
+ let p = project ( )
2128
+ . file ( "Cargo.toml" , crate_manifest)
2129
+ . file ( "src/lib.rs" , "" )
2130
+ . build ( ) ;
2131
+
2132
+ p. cargo ( "generate-lockfile" ) . run ( ) ;
2133
+ let lock_file = p. read_file ( "Cargo.lock" ) ;
2134
+
2135
+ Package :: new ( "compatible" , "1.0.1" ) . publish ( ) ;
2136
+ Package :: new ( "renamed-from" , "1.0.1" ) . publish ( ) ;
2137
+ Package :: new ( "non-semver" , "1.0.1" ) . publish ( ) ;
2138
+ Package :: new ( "transitive-compatible" , "1.0.1" ) . publish ( ) ;
2139
+ Package :: new ( "transitive-incompatible" , "1.0.1" ) . publish ( ) ;
2140
+
2141
+ Package :: new ( "renamed-from" , "2.0.0" ) . publish ( ) ;
2142
+ Package :: new ( "non-semver" , "2.0.0" ) . publish ( ) ;
2143
+ Package :: new ( "transitive-incompatible" , "2.0.0" ) . publish ( ) ;
2144
+
2145
+ p. cargo ( "update -Zunstable-options --breaking compatible renamed-from non-semver transitive-compatible transitive-incompatible" )
2146
+ . masquerade_as_nightly_cargo ( & [ "update-breaking" ] )
2147
+ . with_stderr (
2148
+ "\
2149
+ [UPDATING] `[..]` index
2150
+ " ,
2151
+ )
2152
+ . run ( ) ;
2153
+
2154
+ let crate_manifest_after = p. read_file ( "Cargo.toml" ) ;
2155
+ assert_e2e ( ) . eq ( & crate_manifest_after, crate_manifest) ;
2156
+
2157
+ let lock_file_after = p. read_file ( "Cargo.lock" ) ;
2158
+ assert_e2e ( ) . eq ( & lock_file_after, lock_file) ;
2159
+
2160
+ p. cargo (
2161
+ "update compatible renamed-from non-semver transitive-compatible transitive-incompatible" ,
2162
+ )
2163
+ . with_stderr (
2164
+ "\
2165
+ [UPDATING] `[..]` index
2166
+ [LOCKING] 5 packages to latest compatible versions
2167
+ [UPDATING] compatible v1.0.0 -> v1.0.1
2168
+ [UPDATING] non-semver v1.0.0 -> v1.0.1 (latest: v2.0.0)
2169
+ [UPDATING] renamed-from v1.0.0 -> v1.0.1 (latest: v2.0.0)
2170
+ [UPDATING] transitive-compatible v1.0.0 -> v1.0.1
2171
+ [UPDATING] transitive-incompatible v1.0.0 -> v1.0.1 (latest: v2.0.0)
2172
+ " ,
2173
+ )
2174
+ . run ( ) ;
2175
+ }
2176
+
2177
+ #[ cargo_test]
2178
+ fn update_breaking_without_lock_file ( ) {
2179
+ Package :: new ( "compatible" , "1.0.0" ) . publish ( ) ;
2180
+ Package :: new ( "incompatible" , "1.0.0" ) . publish ( ) ;
2181
+
2182
+ let p = project ( )
2183
+ . file (
2184
+ "Cargo.toml" ,
2185
+ r#"
2186
+ [package]
2187
+ name = "foo"
2188
+ version = "0.0.1"
2189
+ edition = "2015"
2190
+ authors = []
2191
+
2192
+ [dependencies]
2193
+ compatible = "1.0" # Comment
2194
+ incompatible = "1.0" # Comment
2195
+ "# ,
2196
+ )
2197
+ . file ( "src/lib.rs" , "" )
2198
+ . build ( ) ;
2199
+
2200
+ Package :: new ( "compatible" , "1.0.1" ) . publish ( ) ;
2201
+ Package :: new ( "incompatible" , "1.0.1" ) . publish ( ) ;
2202
+
2203
+ Package :: new ( "incompatible" , "2.0.0" ) . publish ( ) ;
2204
+
2205
+ p. cargo ( "update -Zunstable-options --breaking" )
2206
+ . masquerade_as_nightly_cargo ( & [ "update-breaking" ] )
2207
+ . with_stderr (
2208
+ "\
2209
+ [UPDATING] `[..]` index
2210
+ [UPGRADING] incompatible ^1.0 -> ^2.0
2211
+ [LOCKING] 3 packages to latest compatible versions
2212
+ " ,
2213
+ )
2214
+ . run ( ) ;
2215
+ }
2216
+
2217
+ #[ cargo_test]
2218
+ fn update_breaking_spec_version ( ) {
2219
+ Package :: new ( "compatible" , "1.0.0" ) . publish ( ) ;
2220
+ Package :: new ( "incompatible" , "1.0.0" ) . publish ( ) ;
2221
+
2222
+ let p = project ( )
2223
+ . file (
2224
+ "Cargo.toml" ,
2225
+ r#"
2226
+ [package]
2227
+ name = "foo"
2228
+ version = "0.0.1"
2229
+ edition = "2015"
2230
+ authors = []
2231
+
2232
+ [dependencies]
2233
+ compatible = "1.0" # Comment
2234
+ incompatible = "1.0" # Comment
2235
+ "# ,
2236
+ )
2237
+ . file ( "src/lib.rs" , "" )
2238
+ . build ( ) ;
2239
+
2240
+ p. cargo ( "generate-lockfile" ) . run ( ) ;
2241
+
2242
+ Package :: new ( "compatible" , "1.0.1" ) . publish ( ) ;
2243
+ Package :: new ( "incompatible" , "1.0.1" ) . publish ( ) ;
2244
+
2245
+ Package :: new ( "incompatible" , "2.0.0" ) . publish ( ) ;
2246
+
2247
+ // Invalid spec
2248
+ p. cargo ( "update -Zunstable-options --breaking incompatible@foo" )
2249
+ . masquerade_as_nightly_cargo ( & [ "update-breaking" ] )
2250
+ . with_stderr ( "" )
2251
+ . run ( ) ;
2252
+
2253
+ // Spec version not matching our current dependencies
2254
+ p
. cargo ( "update -Zunstable-options --breaking [email protected] " )
2255
+ . masquerade_as_nightly_cargo ( & [ "update-breaking" ] )
2256
+ . with_stderr ( "" )
2257
+ . run ( ) ;
2258
+
2259
+ // Spec source not matching our current dependencies
2260
+ p
. cargo ( "update -Zunstable-options --breaking https://alternative.com#[email protected] " )
2261
+ . masquerade_as_nightly_cargo ( & [ "update-breaking" ] )
2262
+ . with_stderr ( "" )
2263
+ . run ( ) ;
2264
+
2265
+ // Accepted spec
2266
+ p
. cargo ( "update -Zunstable-options --breaking [email protected] " )
2267
+ . masquerade_as_nightly_cargo ( & [ "update-breaking" ] )
2268
+ . with_stderr ( "" )
2269
+ . run ( ) ;
2270
+
2271
+ // Accepted spec, full format
2272
+ Package :: new ( "incompatible" , "3.0.0" ) . publish ( ) ;
2273
+ p
. cargo ( "update -Zunstable-options --breaking https://github.com/rust-lang/crates.io-index#[email protected] " )
2274
+ . masquerade_as_nightly_cargo ( & [ "update-breaking" ] )
2275
+ . with_stderr ( "" )
2276
+ . run ( ) ;
2277
+
2278
+ // Spec matches a dependency that will not be upgraded
2279
+ p
. cargo ( "update -Zunstable-options --breaking [email protected] " )
2280
+ . masquerade_as_nightly_cargo ( & [ "update-breaking" ] )
2281
+ . with_stderr ( "" )
2282
+ . run ( ) ;
2283
+
2284
+ // Non-existing versions
2285
+ p
. cargo ( "update -Zunstable-options --breaking [email protected] " )
2286
+ . masquerade_as_nightly_cargo ( & [ "update-breaking" ] )
2287
+ . with_stderr ( "" )
2288
+ . run ( ) ;
2289
+
2290
+ p
. cargo ( "update -Zunstable-options --breaking [email protected] " )
2291
+ . masquerade_as_nightly_cargo ( & [ "update-breaking" ] )
2292
+ . with_stderr ( "" )
2293
+ . run ( ) ;
2294
+ }
2295
+
2296
+ #[ cargo_test]
2297
+ fn update_breaking_mixed_compatibility ( ) {
2298
+ Package :: new ( "mixed-compatibility" , "1.0.0" ) . publish ( ) ;
2299
+ Package :: new ( "mixed-compatibility" , "2.0.0" ) . publish ( ) ;
2300
+
2301
+ let p = project ( )
2302
+ . file (
2303
+ "Cargo.toml" ,
2304
+ r#"
2305
+ [workspace]
2306
+ members = ["foo", "bar"]
2307
+ "# ,
2308
+ )
2309
+ . file (
2310
+ "foo/Cargo.toml" ,
2311
+ r#"
2312
+ [package]
2313
+ name = "foo"
2314
+ version = "0.0.1"
2315
+ edition = "2015"
2316
+ authors = []
2317
+
2318
+ [dependencies]
2319
+ mixed-compatibility = "1.0"
2320
+ "# ,
2321
+ )
2322
+ . file ( "foo/src/lib.rs" , "" )
2323
+ . file (
2324
+ "bar/Cargo.toml" ,
2325
+ r#"
2326
+ [package]
2327
+ name = "bar"
2328
+ version = "0.0.1"
2329
+ edition = "2015"
2330
+ authors = []
2331
+
2332
+ [dependencies]
2333
+ mixed-compatibility = "2.0"
2334
+ "# ,
2335
+ )
2336
+ . file ( "bar/src/lib.rs" , "" )
2337
+ . build ( ) ;
2338
+
2339
+ p. cargo ( "generate-lockfile" ) . run ( ) ;
2340
+
2341
+ Package :: new ( "mixed-compatibility" , "2.0.1" ) . publish ( ) ;
2342
+
2343
+ p. cargo ( "update -Zunstable-options --breaking" )
2344
+ . masquerade_as_nightly_cargo ( & [ "update-breaking" ] )
2345
+ . with_stderr (
2346
+ "\
2347
+ [UPDATING] `[..]` index
2348
+ [UPGRADING] mixed-compatibility ^1.0 -> ^2.0
2349
+ [LOCKING] 1 package to latest compatible version
2350
+ [ADDING] mixed-compatibility v2.0.1
2351
+ " ,
2352
+ )
2353
+ . run ( ) ;
2354
+ }
2355
+
2356
+ #[ cargo_test]
2357
+ fn update_breaking_mixed_renaming ( ) {
2358
+ Package :: new ( "renamed-from" , "1.0.0" ) . publish ( ) ;
2359
+
2360
+ let p = project ( )
2361
+ . file (
2362
+ "Cargo.toml" ,
2363
+ r#"
2364
+ [workspace]
2365
+ members = ["foo", "bar"]
2366
+ "# ,
2367
+ )
2368
+ . file (
2369
+ "foo/Cargo.toml" ,
2370
+ r#"
2371
+ [package]
2372
+ name = "foo"
2373
+ version = "0.0.1"
2374
+ edition = "2015"
2375
+ authors = []
2376
+
2377
+ [dependencies]
2378
+ renamed-to = { package = "renamed-from", version = "1.0" }
2379
+ "# ,
2380
+ )
2381
+ . file ( "foo/src/lib.rs" , "" )
2382
+ . file (
2383
+ "bar/Cargo.toml" ,
2384
+ r#"
2385
+ [package]
2386
+ name = "bar"
2387
+ version = "0.0.1"
2388
+ edition = "2015"
2389
+ authors = []
2390
+
2391
+ [dependencies]
2392
+ renamed-from = "1.0"
2393
+ "# ,
2394
+ )
2395
+ . file ( "bar/src/lib.rs" , "" )
2396
+ . build ( ) ;
2397
+
2398
+ p. cargo ( "generate-lockfile" ) . run ( ) ;
2399
+
2400
+ Package :: new ( "renamed-from" , "2.0.0" ) . publish ( ) ;
2401
+
2402
+ p. cargo ( "update -Zunstable-options --breaking" )
2403
+ . masquerade_as_nightly_cargo ( & [ "update-breaking" ] )
2404
+ . with_stderr (
2405
+ "\
2406
+ [UPDATING] `[..]` index
2407
+ [UPGRADING] renamed-from ^1.0 -> ^2.0
2408
+ [LOCKING] 1 package to latest compatible version
2409
+ [ADDING] renamed-from v2.0.0
2410
+ " ,
2411
+ )
2412
+ . run ( ) ;
2413
+
2414
+ let foo_manifest = p. read_file ( "foo/Cargo.toml" ) ;
2415
+ let bar_manifest = p. read_file ( "bar/Cargo.toml" ) ;
2416
+
2417
+ assert_e2e ( ) . eq (
2418
+ & foo_manifest,
2419
+ // FIXME: The renamed dependency should not have been upgraded.
2420
+ str![ [ r#"
2421
+
2422
+ [package]
2423
+ name = "foo"
2424
+ version = "0.0.1"
2425
+ edition = "2015"
2426
+ authors = []
2427
+
2428
+ [dependencies]
2429
+ renamed-to = { package = "renamed-from", version = "2.0" }
2430
+ "# ] ] ,
2431
+ ) ;
2432
+
2433
+ assert_e2e ( ) . eq (
2434
+ & bar_manifest,
2435
+ str![ [ r#"
2436
+
2437
+ [package]
2438
+ name = "bar"
2439
+ version = "0.0.1"
2440
+ edition = "2015"
2441
+ authors = []
2442
+
2443
+ [dependencies]
2444
+ renamed-from = "2.0"
2445
+ "# ] ] ,
2446
+ ) ;
2447
+ }
0 commit comments