@@ -930,17 +930,71 @@ fn publish_with_patch() {
930
930
bar = { path = "bar" }
931
931
"# ,
932
932
)
933
- . file ( "src/main.rs" , "extern crate bar; fn main() {}" )
933
+ . file (
934
+ "src/main.rs" ,
935
+ "extern crate bar;
936
+ fn main() {
937
+ bar::newfunc();
938
+ }" ,
939
+ )
934
940
. file ( "bar/Cargo.toml" , & basic_manifest ( "bar" , "1.0.0" ) )
935
- . file ( "bar/src/lib.rs" , "" )
941
+ . file ( "bar/src/lib.rs" , "pub fn newfunc() {} " )
936
942
. build ( ) ;
937
943
938
944
// Check that it works with the patched crate.
939
945
p. cargo ( "build" ) . run ( ) ;
940
946
947
+ // Check that verify fails with patched crate which has new functionality.
941
948
p. cargo ( "publish --index" )
942
949
. arg ( registry_url ( ) . to_string ( ) )
950
+ . with_stderr_contains ( "[..]newfunc[..]" )
943
951
. with_status ( 101 )
944
- . with_stderr_contains ( "[ERROR] published crates cannot contain [patch] sections" )
945
952
. run ( ) ;
953
+
954
+ // Remove the usage of new functionality and try again.
955
+ p. change_file ( "src/main.rs" , "extern crate bar; pub fn main() {}" ) ;
956
+
957
+ p. cargo ( "publish --index" )
958
+ . arg ( registry_url ( ) . to_string ( ) )
959
+ . run ( ) ;
960
+
961
+ // Note, use of `registry` in the deps here is an artifact that this
962
+ // publishes to a fake, local registry that is pretending to be crates.io.
963
+ // Normal publishes would set it to null.
964
+ publish:: validate_upload (
965
+ r#"
966
+ {
967
+ "authors": [],
968
+ "badges": {},
969
+ "categories": [],
970
+ "deps": [
971
+ {
972
+ "default_features": true,
973
+ "features": [],
974
+ "kind": "normal",
975
+ "name": "bar",
976
+ "optional": false,
977
+ "registry": "https://github.com/rust-lang/crates.io-index",
978
+ "target": null,
979
+ "version_req": "^1.0"
980
+ }
981
+ ],
982
+ "description": "foo",
983
+ "documentation": null,
984
+ "features": {},
985
+ "homepage": null,
986
+ "keywords": [],
987
+ "license": "MIT",
988
+ "license_file": null,
989
+ "links": null,
990
+ "name": "foo",
991
+ "readme": null,
992
+ "readme_file": null,
993
+ "repository": null,
994
+ "vers": "0.0.1"
995
+ }
996
+ "# ,
997
+ "foo-0.0.1.crate" ,
998
+ & [ "Cargo.toml" , "Cargo.toml.orig" , "src/main.rs" ] ,
999
+ ) ;
946
1000
}
0 commit comments