| |
@@ -20,6 +20,18 @@
|
| |
CSDIFF_PYLINT = os.path.realpath(os.path.join(os.path.dirname(__file__),
|
| |
'csdiff-pylint'))
|
| |
|
| |
+ def _run_csdiff(old, new, msg):
|
| |
+ popen_diff = Popen(['csdiff', old, new],
|
| |
+ stdout=PIPE)
|
| |
+ diff = popen_diff.communicate()[0].decode('utf-8')
|
| |
+ if diff:
|
| |
+ print("============")
|
| |
+ print(msg)
|
| |
+ print("============")
|
| |
+ print()
|
| |
+ sys.stdout.write(diff)
|
| |
+ return int(bool(diff))
|
| |
+
|
| |
|
| |
def file_type(filename):
|
| |
"""
|
| |
@@ -270,14 +282,15 @@
|
| |
finally:
|
| |
os.chdir(oldcwd)
|
| |
|
| |
- popen_diff = Popen(['csdiff', old_report, new_report],
|
| |
- stdout=PIPE)
|
| |
- diff = popen_diff.communicate()[0].decode('utf-8')
|
| |
- sys.stdout.write(diff)
|
| |
- sys.exit(bool(diff))
|
| |
+ if self.options.print_fixed_errors:
|
| |
+ _run_csdiff(new_report, old_report, "Fixed warnings")
|
| |
+
|
| |
+ sys.exit(_run_csdiff(old_report, new_report, "Added warnings"))
|
| |
+
|
| |
finally:
|
| |
log.debug("removing workdir %s", self.workdir)
|
| |
- shutil.rmtree(self.workdir)
|
| |
+ if not self.options.no_cleanup:
|
| |
+ shutil.rmtree(self.workdir)
|
| |
|
| |
|
| |
def _get_arg_parser():
|
| |
@@ -292,6 +305,19 @@
|
| |
"--log-level",
|
| |
default='error',
|
| |
help="The python logging level, e.g. debug, error, ...")
|
| |
+ parser.add_argument(
|
| |
+ "--no-cleanup",
|
| |
+ action='store_true',
|
| |
+ default=False,
|
| |
+ help=("Keep the temporary working directory, you can use the "
|
| |
+ "--log-level=info switch to see where it is created"),
|
| |
+ )
|
| |
+ parser.add_argument(
|
| |
+ "--print-fixed-errors",
|
| |
+ action='store_true',
|
| |
+ default=False,
|
| |
+ help="Also print defects which were fixed by the changes",
|
| |
+ )
|
| |
return parser
|
| |
|
| |
|
| |