@@ -72,26 +72,32 @@ def check(self, search_paths) -> bool:
7272 non_formatted_files = []
7373
7474 for f in files :
75- print ('Check {}' .format (f ))
75+ print ('Check {}' .format (f ), end = '' )
7676 cmd = "{} --output-replacements-xml {}" .format (Formatter .Executable , f )
7777
7878 process = subprocess .Popen (cmd , shell = True , cwd = os .getcwd (), stdout = subprocess .PIPE , stderr = subprocess .PIPE )
7979 rc = process .wait ()
8080 output = process .communicate ()[0 ]
8181
82- if rc != 0 :
83- final_result = False
84- continue
82+ passed = False
8583
86- # check if there are any replacements
87- s = output .decode ("utf-8" )
88- if len (s ) > 0 :
89- root = ET .fromstring (s )
90- replacements = root .findall ("replacement" )
84+ if rc == 0 :
85+
86+ passed = True
87+ # check if there are any replacements
88+ s = output .decode ("utf-8" )
89+ if len (s ) > 0 :
90+ root = ET .fromstring (s )
91+ replacements = root .findall ("replacement" )
92+
93+ if len (replacements ) > 0 :
94+ passed = False
95+
96+ if not passed :
97+ final_result = False
98+ non_formatted_files .append (f )
9199
92- if len (replacements ) > 0 :
93- final_result = False
94- non_formatted_files .append (f )
100+ print (" - {}" .format ("ok" if passed else "fail" ))
95101
96102 return (final_result , non_formatted_files )
97103
@@ -112,12 +118,16 @@ def check(self, search_paths) -> bool:
112118 c = Formatter ()
113119 if args .check :
114120 passed , files = c .check (args .files )
115- if not passed or len ( files ) > 0 :
121+ if not passed :
116122 if len (files ) > 0 :
123+ print ("-" * 10 )
117124 print ("Files that need formatting:" )
118125 for f in files :
119126 print (" {}" .format (f ))
127+ else :
128+ print ("-" * 10 )
129+ print ("All checks passed" )
120130
121- sys .exit (0 if passed else 1 )
131+ sys .exit (0 if passed else 1 )
122132 else :
123133 c .format (args .files )
0 commit comments