@@ -408,7 +408,7 @@ impl RustwideBuilder {
408
408
std:: fs:: remove_file ( cargo_lock) ?;
409
409
Command :: new ( & self . workspace , self . toolchain . cargo ( ) )
410
410
. cd ( build. host_source_dir ( ) )
411
- . args ( & [ "generate-lockfile" , "-Zno-index-update" ] )
411
+ . args ( & [ "generate-lockfile" ] )
412
412
. run ( ) ?;
413
413
Command :: new ( & self . workspace , self . toolchain . cargo ( ) )
414
414
. cd ( build. host_source_dir ( ) )
@@ -885,9 +885,39 @@ pub(crate) struct BuildResult {
885
885
#[ cfg( test) ]
886
886
mod tests {
887
887
use super :: * ;
888
- use crate :: test:: { assert_redirect, assert_success, wrapper} ;
888
+ use crate :: test:: { assert_redirect, assert_success, wrapper, TestEnvironment } ;
889
889
use serde_json:: Value ;
890
890
891
+ fn remove_cache_files ( env : & TestEnvironment , crate_ : & str , version : & str ) -> Result < ( ) > {
892
+ let paths = [
893
+ format ! ( "cache/index.crates.io-6f17d22bba15001f/{crate_}-{version}.crate" ) ,
894
+ format ! ( "src/index.crates.io-6f17d22bba15001f/{crate_}-{version}" ) ,
895
+ format ! (
896
+ "index/index.crates.io-6f17d22bba15001f/.cache/{}/{}/{crate_}" ,
897
+ & crate_[ 0 ..2 ] ,
898
+ & crate_[ 2 ..4 ]
899
+ ) ,
900
+ ] ;
901
+
902
+ for path in paths {
903
+ let full_path = env
904
+ . config ( )
905
+ . rustwide_workspace
906
+ . join ( "cargo-home/registry" )
907
+ . join ( path) ;
908
+ if full_path. exists ( ) {
909
+ info ! ( "deleting {}" , full_path. display( ) ) ;
910
+ if full_path. is_file ( ) {
911
+ std:: fs:: remove_file ( full_path) ?;
912
+ } else {
913
+ std:: fs:: remove_dir_all ( full_path) ?;
914
+ }
915
+ }
916
+ }
917
+
918
+ Ok ( ( ) )
919
+ }
920
+
891
921
#[ test]
892
922
#[ ignore]
893
923
fn test_build_crate ( ) {
@@ -1136,22 +1166,7 @@ mod tests {
1136
1166
env. override_config ( |cfg| cfg. include_default_targets = false ) ;
1137
1167
1138
1168
// if the corrected dependency of the crate was already downloaded we need to remove it
1139
- let crate_file = env. config ( ) . rustwide_workspace . join (
1140
- "cargo-home/registry/cache/github.com-1ecc6299db9ec823/rand_core-0.5.1.crate" ,
1141
- ) ;
1142
- let src_dir = env
1143
- . config ( )
1144
- . rustwide_workspace
1145
- . join ( "cargo-home/registry/src/github.com-1ecc6299db9ec823/rand_core-0.5.1" ) ;
1146
-
1147
- if crate_file. exists ( ) {
1148
- info ! ( "deleting {}" , crate_file. display( ) ) ;
1149
- std:: fs:: remove_file ( crate_file) ?;
1150
- }
1151
- if src_dir. exists ( ) {
1152
- info ! ( "deleting {}" , src_dir. display( ) ) ;
1153
- std:: fs:: remove_dir_all ( src_dir) ?;
1154
- }
1169
+ remove_cache_files ( env, "rand_core" , "0.5.1" ) ?;
1155
1170
1156
1171
// Specific setup required:
1157
1172
// * crate has a binary so that it is published with a lockfile
@@ -1169,6 +1184,28 @@ mod tests {
1169
1184
} ) ;
1170
1185
}
1171
1186
1187
+ #[ test]
1188
+ #[ ignore]
1189
+ fn test_locked_fails_unlocked_needs_new_unknown_deps ( ) {
1190
+ wrapper ( |env| {
1191
+ env. override_config ( |cfg| cfg. include_default_targets = false ) ;
1192
+
1193
+ // if the corrected dependency of the crate was already downloaded we need to remove it
1194
+ remove_cache_files ( env, "value-bag-sval2" , "1.4.1" ) ?;
1195
+
1196
+ // Similar to above, this crate fails to build with the published
1197
+ // lockfile, but generating a new working lockfile requires
1198
+ // introducing a completely new dependency (not just version) which
1199
+ // would not have had its details pulled down from the sparse-index.
1200
+ let crate_ = "docs_rs_test_incorrect_lockfile" ;
1201
+ let version = "0.2.0" ;
1202
+ let mut builder = RustwideBuilder :: init ( env) . unwrap ( ) ;
1203
+ assert ! ( builder. build_package( crate_, version, PackageKind :: CratesIo ) ?) ;
1204
+
1205
+ Ok ( ( ) )
1206
+ } ) ;
1207
+ }
1208
+
1172
1209
#[ test]
1173
1210
#[ ignore]
1174
1211
fn test_rustflags_are_passed_to_build_script ( ) {
0 commit comments