@@ -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,324 @@ 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
+ p
. cargo ( "update -Zunstable-options --breaking [email protected] " )
2248
+ . masquerade_as_nightly_cargo ( & [ "update-breaking" ] )
2249
+ . with_stderr (
2250
+ // FIXME: This is wrong.
2251
+ "\
2252
+ ",
2253
+ )
2254
+ . run ( ) ;
2255
+
2256
+ p
. cargo ( "update [email protected] " )
2257
+ . with_stderr (
2258
+ "\
2259
+ [UPDATING] `[..]` index
2260
+ [LOCKING] 1 package to latest compatible version
2261
+ [UPDATING] compatible v1.0.0 -> v1.0.1
2262
+ [NOTE] pass `--verbose` to see 1 unchanged dependencies behind latest
2263
+ " ,
2264
+ )
2265
+ . run ( ) ;
2266
+ }
2267
+
2268
+ #[ cargo_test]
2269
+ fn update_breaking_mixed_compatibility ( ) {
2270
+ Package :: new ( "mixed-compatibility" , "1.0.0" ) . publish ( ) ;
2271
+ Package :: new ( "mixed-compatibility" , "2.0.0" ) . publish ( ) ;
2272
+
2273
+ let p = project ( )
2274
+ . file (
2275
+ "Cargo.toml" ,
2276
+ r#"
2277
+ [workspace]
2278
+ members = ["foo", "bar"]
2279
+ "# ,
2280
+ )
2281
+ . file (
2282
+ "foo/Cargo.toml" ,
2283
+ r#"
2284
+ [package]
2285
+ name = "foo"
2286
+ version = "0.0.1"
2287
+ edition = "2015"
2288
+ authors = []
2289
+
2290
+ [dependencies]
2291
+ mixed-compatibility = "1.0"
2292
+ "# ,
2293
+ )
2294
+ . file ( "foo/src/lib.rs" , "" )
2295
+ . file (
2296
+ "bar/Cargo.toml" ,
2297
+ r#"
2298
+ [package]
2299
+ name = "bar"
2300
+ version = "0.0.1"
2301
+ edition = "2015"
2302
+ authors = []
2303
+
2304
+ [dependencies]
2305
+ mixed-compatibility = "2.0"
2306
+ "# ,
2307
+ )
2308
+ . file ( "bar/src/lib.rs" , "" )
2309
+ . build ( ) ;
2310
+
2311
+ p. cargo ( "generate-lockfile" ) . run ( ) ;
2312
+
2313
+ Package :: new ( "mixed-compatibility" , "2.0.1" ) . publish ( ) ;
2314
+
2315
+ p. cargo ( "update -Zunstable-options --breaking" )
2316
+ . masquerade_as_nightly_cargo ( & [ "update-breaking" ] )
2317
+ . with_stderr (
2318
+ "\
2319
+ [UPDATING] `[..]` index
2320
+ [UPGRADING] mixed-compatibility ^1.0 -> ^2.0
2321
+ [LOCKING] 1 package to latest compatible version
2322
+ [ADDING] mixed-compatibility v2.0.1
2323
+ " ,
2324
+ )
2325
+ . run ( ) ;
2326
+ }
2327
+
2328
+ #[ cargo_test]
2329
+ fn update_breaking_mixed_renaming ( ) {
2330
+ Package :: new ( "renamed-from" , "1.0.0" ) . publish ( ) ;
2331
+
2332
+ let p = project ( )
2333
+ . file (
2334
+ "Cargo.toml" ,
2335
+ r#"
2336
+ [workspace]
2337
+ members = ["foo", "bar"]
2338
+ "# ,
2339
+ )
2340
+ . file (
2341
+ "foo/Cargo.toml" ,
2342
+ r#"
2343
+ [package]
2344
+ name = "foo"
2345
+ version = "0.0.1"
2346
+ edition = "2015"
2347
+ authors = []
2348
+
2349
+ [dependencies]
2350
+ renamed-to = { package = "renamed-from", version = "1.0" }
2351
+ "# ,
2352
+ )
2353
+ . file ( "foo/src/lib.rs" , "" )
2354
+ . file (
2355
+ "bar/Cargo.toml" ,
2356
+ r#"
2357
+ [package]
2358
+ name = "bar"
2359
+ version = "0.0.1"
2360
+ edition = "2015"
2361
+ authors = []
2362
+
2363
+ [dependencies]
2364
+ renamed-from = "1.0"
2365
+ "# ,
2366
+ )
2367
+ . file ( "bar/src/lib.rs" , "" )
2368
+ . build ( ) ;
2369
+
2370
+ p. cargo ( "generate-lockfile" ) . run ( ) ;
2371
+
2372
+ Package :: new ( "renamed-from" , "2.0.0" ) . publish ( ) ;
2373
+
2374
+ p. cargo ( "update -Zunstable-options --breaking" )
2375
+ . masquerade_as_nightly_cargo ( & [ "update-breaking" ] )
2376
+ . with_stderr (
2377
+ "\
2378
+ [UPDATING] `[..]` index
2379
+ [UPGRADING] renamed-from ^1.0 -> ^2.0
2380
+ [LOCKING] 1 package to latest compatible version
2381
+ [ADDING] renamed-from v2.0.0
2382
+ " ,
2383
+ )
2384
+ . run ( ) ;
2385
+
2386
+ let foo_manifest = p. read_file ( "foo/Cargo.toml" ) ;
2387
+ let bar_manifest = p. read_file ( "bar/Cargo.toml" ) ;
2388
+
2389
+ assert_e2e ( ) . eq (
2390
+ & foo_manifest,
2391
+ str![ [ r#"
2392
+
2393
+ [package]
2394
+ name = "foo"
2395
+ version = "0.0.1"
2396
+ edition = "2015"
2397
+ authors = []
2398
+
2399
+ [dependencies]
2400
+ renamed-to = { package = "renamed-from", version = "2.0" }
2401
+ "# ] ] ,
2402
+ ) ;
2403
+
2404
+ assert_e2e ( ) . eq (
2405
+ & bar_manifest,
2406
+ str![ [ r#"
2407
+
2408
+ [package]
2409
+ name = "bar"
2410
+ version = "0.0.1"
2411
+ edition = "2015"
2412
+ authors = []
2413
+
2414
+ [dependencies]
2415
+ renamed-from = "2.0"
2416
+ "# ] ] ,
2417
+ ) ;
2418
+ }
0 commit comments