1- use diffy:: { self } ;
1+ use diffy;
22use std:: env;
33use std:: fmt:: { Debug , Display } ;
44use std:: io:: { self , Write } ;
@@ -82,8 +82,8 @@ impl Diff {
8282
8383// will be used in future PRs, just added to make the compiler happy
8484pub struct CheckDiffRunners {
85- pub feature_runner : RustfmtRunner ,
86- pub src_runner : RustfmtRunner ,
85+ feature_runner : RustfmtRunner ,
86+ src_runner : RustfmtRunner ,
8787}
8888
8989pub struct RustfmtRunner {
@@ -106,6 +106,14 @@ impl CheckDiffRunners {
106106 feature_format,
107107 } )
108108 }
109+
110+ pub fn get_feature_runner ( self ) -> RustfmtRunner {
111+ self . feature_runner
112+ }
113+
114+ pub fn get_src_runner ( self ) -> RustfmtRunner {
115+ self . src_runner
116+ }
109117}
110118
111119impl RustfmtRunner {
@@ -124,10 +132,9 @@ impl RustfmtRunner {
124132 return Ok ( binary_version. to_string ( ) ) ;
125133 }
126134
127- // Run rusfmt with the --check flag to see if a diff is produced. Runs on the code specified
135+ // Run rusfmt to see if a diff is produced. Runs on the code specified
128136 //
129137 // Parameters:
130- // binary_path: Path to a rustfmt binary
131138 // code: Code to run the binary on
132139 // config: Any additional configuration options to pass to rustfmt
133140 //
@@ -156,6 +163,8 @@ impl RustfmtRunner {
156163 }
157164}
158165
166+ /// Creates a configuration in the following form:
167+ /// <config_name>=<config_val>, <config_name>=<config_val>, ...
159168fn create_config_arg ( config : & Option < Vec < String > > ) -> String {
160169 let config_arg: String = match config {
161170 Some ( configs) => {
@@ -363,6 +372,7 @@ pub fn compile_rustfmt(
363372 } ) ;
364373}
365374
375+ /// Searches for rust files in the particular path and returns an iterator to them.
366376pub fn search_for_rs_files ( repo : & Path ) -> impl Iterator < Item = PathBuf > {
367377 return WalkDir :: new ( repo) . into_iter ( ) . filter_map ( |e| match e. ok ( ) {
368378 Some ( entry) => {
@@ -376,6 +386,8 @@ pub fn search_for_rs_files(repo: &Path) -> impl Iterator<Item = PathBuf> {
376386 } ) ;
377387}
378388
389+ /// Calculates the number of errors when running the compiled binary and the feature binary on the
390+ /// repo specified with the specific configs.
379391pub fn check_diff ( config : Option < Vec < String > > , runners : CheckDiffRunners , repo : & Path ) -> i32 {
380392 let mut errors = 0 ;
381393 let iter = search_for_rs_files ( repo) ;
0 commit comments