@@ -72,26 +72,32 @@ def check(self, search_paths) -> bool:
72
72
non_formatted_files = []
73
73
74
74
for f in files :
75
- print ('Check {}' .format (f ))
75
+ print ('Check {}' .format (f ), end = '' )
76
76
cmd = "{} --output-replacements-xml {}" .format (Formatter .Executable , f )
77
77
78
78
process = subprocess .Popen (cmd , shell = True , cwd = os .getcwd (), stdout = subprocess .PIPE , stderr = subprocess .PIPE )
79
79
rc = process .wait ()
80
80
output = process .communicate ()[0 ]
81
81
82
- if rc != 0 :
83
- final_result = False
84
- continue
82
+ passed = False
85
83
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 )
91
99
92
- if len (replacements ) > 0 :
93
- final_result = False
94
- non_formatted_files .append (f )
100
+ print (" - {}" .format ("ok" if passed else "fail" ))
95
101
96
102
return (final_result , non_formatted_files )
97
103
@@ -112,12 +118,16 @@ def check(self, search_paths) -> bool:
112
118
c = Formatter ()
113
119
if args .check :
114
120
passed , files = c .check (args .files )
115
- if not passed or len ( files ) > 0 :
121
+ if not passed :
116
122
if len (files ) > 0 :
123
+ print ("-" * 10 )
117
124
print ("Files that need formatting:" )
118
125
for f in files :
119
126
print (" {}" .format (f ))
127
+ else :
128
+ print ("-" * 10 )
129
+ print ("All checks passed" )
120
130
121
- sys .exit (0 if passed else 1 )
131
+ sys .exit (0 if passed else 1 )
122
132
else :
123
133
c .format (args .files )
0 commit comments