@@ -2942,6 +2942,97 @@ fn ignore_invalid_json_lines() {
29422942 p. cargo ( "check" ) . run ( ) ;
29432943}
29442944
2945+ #[ cargo_test]
2946+ fn invalid_json_lines_error ( ) {
2947+ Package :: new ( "foo" , "0.1.0" )
2948+ . rust_version ( "1.0" )
2949+ . schema_version ( 2 )
2950+ . publish ( ) ;
2951+ Package :: new ( "foo" , "0.1.1" )
2952+ // Bad name field, too corrupt to use
2953+ . invalid_index_line ( true )
2954+ . publish ( ) ;
2955+ Package :: new ( "foo" , "0.1.2" )
2956+ // Bad version field, too corrupt to use
2957+ . index_line (
2958+ r#"{"cksum":"7ca5fc2301ad96ade45356faf53225aea36437d99930bbfa951155c01faecf79","deps":[],"features":{},"links":null,"name":"foo","vers":"bad","yanked":false,"rust_version":"1.2345","v":1000000000}"# ,
2959+ )
2960+ . publish ( ) ;
2961+ Package :: new ( "foo" , "0.1.3" )
2962+ // Bad field, report rust version
2963+ . index_line (
2964+ r#"{"cksum":"7ca5fc2301ad96ade45356faf53225aea36437d99930bbfa951155c01faecf79","deps":[],"features":"bad","links":null,"name":"foo","vers":"0.1.3","yanked":false,"rust_version":"1.2345","v":1000000000}"# ,
2965+ )
2966+ . publish ( ) ;
2967+ Package :: new ( "foo" , "0.1.4" )
2968+ // Bad field, report schema
2969+ . index_line (
2970+ r#"{"cksum":"7ca5fc2301ad96ade45356faf53225aea36437d99930bbfa951155c01faecf79","deps":[],"features":"bad","links":null,"name":"foo","vers":"0.1.4","yanked":false,"v":1000000000}"# ,
2971+ )
2972+ . publish ( ) ;
2973+ Package :: new ( "foo" , "0.1.5" )
2974+ // Bad field, report error
2975+ . index_line (
2976+ r#"{"cksum":"7ca5fc2301ad96ade45356faf53225aea36437d99930bbfa951155c01faecf79","deps":[],"features":"bad","links":null,"name":"foo","vers":"0.1.5","yanked":false}"# ,
2977+ )
2978+ . publish ( ) ;
2979+ Package :: new ( "foo" , "0.1.6" )
2980+ // Bad field with bad rust version, report schema
2981+ . index_line (
2982+ r#"{"cksum":"7ca5fc2301ad96ade45356faf53225aea36437d99930bbfa951155c01faecf79","deps":[],"features":"bad","links":null,"name":"foo","vers":"0.1.6","yanked":false,"rust_version":"bad","v":1000000000}"# ,
2983+ )
2984+ . publish ( ) ;
2985+ Package :: new ( "foo" , "0.1.7" )
2986+ // Bad field with bad rust version and schema, report error
2987+ . index_line (
2988+ r#"{"cksum":"7ca5fc2301ad96ade45356faf53225aea36437d99930bbfa951155c01faecf79","deps":[],"features":"bad","links":null,"name":"foo","vers":"0.1.7","yanked":false,"rust_version":"bad","v":"bad"}"# ,
2989+ )
2990+ . publish ( ) ;
2991+ Package :: new ( "foo" , "0.2.0" ) . publish ( ) ;
2992+
2993+ let p = project ( )
2994+ . file (
2995+ "Cargo.toml" ,
2996+ r#"
2997+ [package]
2998+ name = "a"
2999+ version = "0.5.0"
3000+ edition = "2015"
3001+ authors = []
3002+
3003+ [dependencies]
3004+ foo = "0.1.1"
3005+ "# ,
3006+ )
3007+ . file ( "src/lib.rs" , "" )
3008+ . build ( ) ;
3009+
3010+ p. cargo ( "generate-lockfile" )
3011+ . with_status ( 101 )
3012+ . with_stderr_data ( str![ [ r#"
3013+ [UPDATING] `dummy-registry` index
3014+ [ERROR] failed to select a version for the requirement `foo = "^0.1.1"`
3015+ candidate versions found which didn't match: 0.2.0, 0.1.0
3016+ location searched: `dummy-registry` index (which is replacing registry `crates-io`)
3017+ required by package `a v0.5.0 ([ROOT]/foo)`
3018+ perhaps a crate was updated and forgotten to be re-vendored?
3019+
3020+ "# ] ] )
3021+ . run ( ) ;
3022+ p. cargo ( "generate-lockfile" )
3023+ . with_status ( 101 )
3024+ . with_stderr_data ( str![ [ r#"
3025+ [UPDATING] `dummy-registry` index
3026+ [ERROR] failed to select a version for the requirement `foo = "^0.1.1"`
3027+ candidate versions found which didn't match: 0.2.0, 0.1.0
3028+ location searched: `dummy-registry` index (which is replacing registry `crates-io`)
3029+ required by package `a v0.5.0 ([ROOT]/foo)`
3030+ perhaps a crate was updated and forgotten to be re-vendored?
3031+
3032+ "# ] ] )
3033+ . run ( ) ;
3034+ }
3035+
29453036#[ cargo_test]
29463037fn readonly_registry_still_works_http ( ) {
29473038 let _server = setup_http ( ) ;
0 commit comments