Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

invalid exit code with -j0 and --exit-code option #545

Merged
merged 2 commits into from
May 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion autopep8.py
Original file line number Diff line number Diff line change
Expand Up @@ -4363,7 +4363,12 @@ def main(argv=None, apply_config=True):
assert len(args.files) == 1
assert not args.recursive

ret = fix_multiple_files(args.files, args, sys.stdout)
results = fix_multiple_files(args.files, args, sys.stdout)
if args.diff:
ret = any([len(ret) != 0 for ret in results])
else:
# with in-place option
ret = any([ret is not None for ret in results])
if args.exit_code and ret:
return EXIT_CODE_EXISTS_DIFF
except KeyboardInterrupt:
Expand Down
6 changes: 6 additions & 0 deletions test/test_autopep8.py
Original file line number Diff line number Diff line change
Expand Up @@ -5244,6 +5244,12 @@ def test_non_diff_with_exit_code_option(self):
self.assertEqual('', '\n'.join(result.split('\n')[3:]))
self.assertEqual(retcode, autopep8.EXIT_CODE_OK)

def test_non_diff_with_exit_code_and_jobs_options(self):
line = "'abc'\n"
with autopep8_subprocess(line, ['-j0', '--diff', '--exit-code']) as (result, retcode):
self.assertEqual('', '\n'.join(result.split('\n')[3:]))
self.assertEqual(retcode, autopep8.EXIT_CODE_OK)

def test_diff_with_empty_file(self):
with autopep8_subprocess('', ['--diff']) as (result, retcode):
self.assertEqual('\n'.join(result.split('\n')[3:]), '')
Expand Down