@@ -300,6 +300,14 @@ mod tests {
300300 extract_path
301301 }
302302
303+ fn variant_hash ( src : String ) -> String {
304+ use sha1:: Digest ;
305+ let mut hasher = sha1:: Sha1 :: new ( ) ;
306+ hasher. update ( src) ;
307+ let hash = hasher. finalize ( ) ;
308+ format ! ( "h{hash:x}" ) [ ..8 ] . to_string ( )
309+ }
310+
303311 #[ test]
304312 fn test_pkg_hash ( ) {
305313 let tmp = tmp ( "test_pkg_hash" ) ;
@@ -308,23 +316,11 @@ mod tests {
308316 assert ! ( rattler_build. status. success( ) ) ;
309317
310318 let pkg = get_package ( tmp. as_dir ( ) , "pkg_hash" . to_string ( ) ) ;
311- let variant = [ ( "target_platform" , host_subdir ( ) ) ]
312- . into_iter ( )
313- . map ( |( k, v) | ( k. into ( ) , v. into ( ) ) )
314- . collect :: < std:: collections:: BTreeMap < _ , _ > > ( ) ;
315- let hash = rattler_build:: hash:: HashInfo :: from_variant (
316- & variant,
317- & rattler_conda_types:: NoArchType :: none ( ) ,
318- )
319- . to_string ( ) ;
320- let pkg_hash = format ! ( "pkg_hash-1.0.0-{}_my_pkg.tar.bz2" , hash) ;
319+ // yes this was broken because in rust default formatting for map does include that one space in the middle!
320+ let expected_hash = variant_hash ( format ! ( "{{\" target_platform\" : \" {}\" }}" , host_subdir( ) ) ) ;
321+ let pkg_hash = format ! ( "pkg_hash-1.0.0-{expected_hash}_my_pkg.tar.bz2" ) ;
321322 let pkg = pkg. display ( ) . to_string ( ) ;
322- assert ! (
323- pkg. ends_with( & pkg_hash) ,
324- "{} does not end with {}" ,
325- pkg,
326- pkg_hash
327- ) ;
323+ assert ! ( pkg. ends_with( & pkg_hash) ) ;
328324 }
329325
330326 #[ test]
@@ -654,15 +650,10 @@ package:
654650 version: 1.0.0
655651build:
656652 script:
657- content: |
658- echo "Testing Python installation"
659- python --version
660- python --help
653+ content: ${{ PYTHON }} --help
661654requirements:
662655 host:
663656 - python
664- build:
665- - python
666657"# ;
667658 run_build_from_yaml_string ( recipe_content. to_string ( ) ) ;
668659 }
@@ -677,7 +668,7 @@ package:
677668build:
678669 script:
679670 content:
680- - python --help
671+ - ${{ PYTHON }} --help
681672requirements:
682673 host:
683674 - python
0 commit comments