@@ -1156,6 +1156,125 @@ src/lib.rs
1156
1156
. run ( ) ;
1157
1157
}
1158
1158
1159
+ #[ cargo_test]
1160
+ fn dirty_file_outside_pkg_root_considered_dirty ( ) {
1161
+ if !symlink_supported ( ) {
1162
+ return ;
1163
+ }
1164
+ let ( p, repo) = git:: new_repo ( "foo" , |p| {
1165
+ p. file (
1166
+ "Cargo.toml" ,
1167
+ r#"
1168
+ [workspace]
1169
+ members = ["isengard"]
1170
+ resolver = "2"
1171
+ [workspace.package]
1172
+ edition = "2015"
1173
+ "# ,
1174
+ )
1175
+ . file ( "LICENSE" , "before" )
1176
+ . file ( "README.md" , "before" )
1177
+ . file (
1178
+ "isengard/Cargo.toml" ,
1179
+ r#"
1180
+ [package]
1181
+ name = "isengard"
1182
+ edition.workspace = true
1183
+ homepage = "saruman"
1184
+ description = "saruman"
1185
+ license-file = "../LICENSE"
1186
+ "# ,
1187
+ )
1188
+ . file ( "isengard/src/lib.rs" , "" )
1189
+ . symlink ( "README.md" , "isengard/README.md" )
1190
+ } ) ;
1191
+ git:: commit ( & repo) ;
1192
+
1193
+ // Change files outside pkg root should be treated as dirty.
1194
+ // The next `cargo package` is expected to fail.
1195
+ //
1196
+ // * relative path outside pkg root of package.{license-file,readme}
1197
+ // should be considered dirty
1198
+ p. change_file ( "LICENSE" , "after" ) ;
1199
+ // * symlink to outside pkg root of package.{license-file,readme}
1200
+ // should be considered dirty
1201
+ p. change_file ( "README.md" , "after" ) ;
1202
+ // * when workspace inheritance is involved and changed,
1203
+ // pkg should be considered dirty
1204
+ p. change_file (
1205
+ "Cargo.toml" ,
1206
+ r#"
1207
+ [workspace]
1208
+ members = ["isengard"]
1209
+ resolver = "2"
1210
+
1211
+ [workspace.package]
1212
+ edition = "2021"
1213
+ "# ,
1214
+ ) ;
1215
+
1216
+ // Ensure dirty files be reported.
1217
+ p. cargo ( "package --workspace --no-verify" )
1218
+ . with_stderr_data ( str![ [ r#"
1219
+ [PACKAGING] isengard v0.0.0 ([ROOT]/foo/isengard)
1220
+ [PACKAGED] 7 files, [FILE_SIZE]B ([FILE_SIZE]B compressed)
1221
+
1222
+ "# ] ] )
1223
+ . run ( ) ;
1224
+
1225
+ let cargo_toml = str![ [ r##"
1226
+ # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
1227
+ #
1228
+ # When uploading crates to the registry Cargo will automatically
1229
+ # "normalize" Cargo.toml files for maximal compatibility
1230
+ # with all versions of Cargo and also rewrite `path` dependencies
1231
+ # to registry (e.g., crates.io) dependencies.
1232
+ #
1233
+ # If you are reading this file be aware that the original Cargo.toml
1234
+ # will likely look very different (and much more reasonable).
1235
+ # See Cargo.toml.orig for the original contents.
1236
+
1237
+ [package]
1238
+ edition = "2021"
1239
+ name = "isengard"
1240
+ build = false
1241
+ autolib = false
1242
+ autobins = false
1243
+ autoexamples = false
1244
+ autotests = false
1245
+ autobenches = false
1246
+ description = "saruman"
1247
+ homepage = "saruman"
1248
+ readme = "README.md"
1249
+ license-file = "LICENSE"
1250
+
1251
+ [lib]
1252
+ name = "isengard"
1253
+ path = "src/lib.rs"
1254
+
1255
+ "## ] ] ;
1256
+
1257
+ let f = File :: open ( & p. root ( ) . join ( "target/package/isengard-0.0.0.crate" ) ) . unwrap ( ) ;
1258
+ validate_crate_contents (
1259
+ f,
1260
+ "isengard-0.0.0.crate" ,
1261
+ & [
1262
+ ".cargo_vcs_info.json" ,
1263
+ "Cargo.toml" ,
1264
+ "Cargo.toml.orig" ,
1265
+ "src/lib.rs" ,
1266
+ "Cargo.lock" ,
1267
+ "LICENSE" ,
1268
+ "README.md" ,
1269
+ ] ,
1270
+ [
1271
+ ( "README.md" , str![ "after" ] ) ,
1272
+ ( "LICENSE" , str![ "after" ] ) ,
1273
+ ( "Cargo.toml" , cargo_toml) ,
1274
+ ] ,
1275
+ ) ;
1276
+ }
1277
+
1159
1278
#[ cargo_test]
1160
1279
fn issue_13695_allow_dirty_vcs_info ( ) {
1161
1280
let p = project ( )
0 commit comments