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

[codemod] add integration test for show errors from formatter subprocess call #289

Merged
merged 1 commit into from
Apr 23, 2020

Conversation

jimmylai
Copy link
Contributor

@jimmylai jimmylai commented Apr 23, 2020

Summary

Without the fix, it shows error like this and it's not useful to understand the cause.

Traceback (most recent call last):
  File "/Users/jimmylai/github/LibCST/libcst/codemod/_cli.py", line 334, in _parallel_exec_process_stub
    newcode = invoke_formatter(formatter_args, newcode)
  File "/Users/jimmylai/github/LibCST/libcst/codemod/_cli.py", line 63, in invoke_formatter
    encoding=None if work_with_bytes else "utf-8",
  File "/Users/jimmylai/anaconda3/lib/python3.7/subprocess.py", line 395, in check_output
    **kwargs).stdout
  File "/Users/jimmylai/anaconda3/lib/python3.7/subprocess.py", line 487, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['/Users/jimmylai/github/libcst-env/bin/black', '-']' returned non-zero exit status 123.

Failed to codemod /Users/jimmylai/github/LibCST/libcst/codemod/tests/codemod_formatter_error_input.py

With the fix, it includes those detail to make debug easy.

Codemodding /Users/jimmylai/github/LibCST/libcst/codemod/tests/codemod_formatter_error_input.py
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
#
# pyre-strict

from contextlib import AsyncExitStack


def fun():
    # this is an explicit syntax error to cause formatter error
    async with AsyncExitStack() as stack:
        pass

error: cannot format -: Cannot parse: 13:10:     async with AsyncExitStack() as stack:

This is for fixing issue @lexprfuncall had.

Test Plan

added test case.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Apr 23, 2020
@jimmylai jimmylai force-pushed the formatting_error branch 8 times, most recently from 0005fe9 to b41c2cf Compare April 23, 2020 20:09
@jimmylai jimmylai requested a review from carljm April 23, 2020 20:17
@carljm carljm merged commit 940647e into Instagram:master Apr 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants