@@ -32,6 +32,13 @@ fn get_toml(file: &Path) -> Result<TomlConfig, toml::de::Error> {
3232 toml:: from_str ( & contents) . and_then ( |table : toml:: Value | TomlConfig :: deserialize ( table) )
3333}
3434
35+ fn modified ( upstream : impl Into < String > , changes : & [ & str ] ) -> PathFreshness {
36+ PathFreshness :: HasLocalModifications {
37+ upstream : upstream. into ( ) ,
38+ modifications : changes. iter ( ) . copied ( ) . map ( PathBuf :: from) . collect ( ) ,
39+ }
40+ }
41+
3542#[ test]
3643fn download_ci_llvm ( ) {
3744 let config = TestCtx :: new ( ) . config ( "check" ) . create_config ( ) ;
@@ -692,7 +699,7 @@ fn test_pr_ci_changed_in_pr() {
692699 let sha = ctx. create_upstream_merge ( & [ "a" ] ) ;
693700 ctx. create_nonupstream_merge ( & [ "b" ] ) ;
694701 let src = ctx. check_modifications ( & [ "b" ] , CiEnv :: GitHubActions ) ;
695- assert_eq ! ( src, PathFreshness :: HasLocalModifications { upstream : sha } ) ;
702+ assert_eq ! ( src, modified ( sha, & [ "b" ] ) ) ;
696703 } ) ;
697704}
698705
@@ -712,7 +719,7 @@ fn test_auto_ci_changed_in_pr() {
712719 let sha = ctx. create_upstream_merge ( & [ "a" ] ) ;
713720 ctx. create_upstream_merge ( & [ "b" , "c" ] ) ;
714721 let src = ctx. check_modifications ( & [ "c" , "d" ] , CiEnv :: GitHubActions ) ;
715- assert_eq ! ( src, PathFreshness :: HasLocalModifications { upstream : sha } ) ;
722+ assert_eq ! ( src, modified ( sha, & [ "c" ] ) ) ;
716723 } ) ;
717724}
718725
@@ -723,10 +730,7 @@ fn test_local_uncommitted_modifications() {
723730 ctx. create_branch ( "feature" ) ;
724731 ctx. modify ( "a" ) ;
725732
726- assert_eq ! (
727- ctx. check_modifications( & [ "a" , "d" ] , CiEnv :: None ) ,
728- PathFreshness :: HasLocalModifications { upstream: sha }
729- ) ;
733+ assert_eq ! ( ctx. check_modifications( & [ "a" , "d" ] , CiEnv :: None ) , modified( sha, & [ "a" ] ) , ) ;
730734 } ) ;
731735}
732736
@@ -741,10 +745,7 @@ fn test_local_committed_modifications() {
741745 ctx. modify ( "a" ) ;
742746 ctx. commit ( ) ;
743747
744- assert_eq ! (
745- ctx. check_modifications( & [ "a" , "d" ] , CiEnv :: None ) ,
746- PathFreshness :: HasLocalModifications { upstream: sha }
747- ) ;
748+ assert_eq ! ( ctx. check_modifications( & [ "a" , "d" ] , CiEnv :: None ) , modified( sha, & [ "a" ] ) , ) ;
748749 } ) ;
749750}
750751
@@ -757,10 +758,7 @@ fn test_local_committed_modifications_subdirectory() {
757758 ctx. modify ( "a/b/d" ) ;
758759 ctx. commit ( ) ;
759760
760- assert_eq ! (
761- ctx. check_modifications( & [ "a/b" ] , CiEnv :: None ) ,
762- PathFreshness :: HasLocalModifications { upstream: sha }
763- ) ;
761+ assert_eq ! ( ctx. check_modifications( & [ "a/b" ] , CiEnv :: None ) , modified( sha, & [ "a/b/d" ] ) , ) ;
764762 } ) ;
765763}
766764
@@ -836,11 +834,11 @@ fn test_local_changes_negative_path() {
836834 ) ;
837835 assert_eq ! (
838836 ctx. check_modifications( & [ ":!c" ] , CiEnv :: None ) ,
839- PathFreshness :: HasLocalModifications { upstream: upstream . clone ( ) }
837+ modified ( & upstream, & [ "b" , "d" ] ) ,
840838 ) ;
841839 assert_eq ! (
842840 ctx. check_modifications( & [ ":!d" , ":!x" ] , CiEnv :: None ) ,
843- PathFreshness :: HasLocalModifications { upstream }
841+ modified ( & upstream, & [ "b" ] ) ,
844842 ) ;
845843 } ) ;
846844}
0 commit comments