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

Output stderr in V2 test rule #7694

Merged
merged 4 commits into from May 10, 2019

Conversation

Projects
None yet
3 participants
@Eric-Arellano
Copy link
Contributor

commented May 9, 2019

Problem

Implements #7388. Swallowing stderr makes debugging very difficult.

Important clarification: failing tests will write to stdout, meaning that we do already output any message captured by Pytest. Instead, this PR is meant to log issues that occur before Pytest executes, such as issues from Pants.

Solution

Follow the convention established by #7676 to output {address} stderr:, followed by the stderr.

did_any_fail = True
if test_result.stderr:
# NB: we write to stdout, rather than to stderr, to avoid potential issues interleaving the
# two streams.

This comment has been minimized.

Copy link
@Eric-Arellano

Eric-Arellano May 9, 2019

Author Contributor

Would be helpful to sanity check that this is the right behavior.

This decision came out of trying to implement test_stderr. I realized that if we wrote to stderr, we would still be writing some things to stdout like the test summary, and that it would be non-trivial to test how the two interleave.

Beyond testing, I think that the control flow of using the for loop means that for the end user, we would be interleaving correctly. If this is the case, perhaps out of correctness we should write to stderr and accept that it will make the tests a little bit more complex.

This comment has been minimized.

Copy link
@stuhood

stuhood May 9, 2019

Member

Yep, writing to stdout here makes sense I think.

@stuhood

stuhood approved these changes May 9, 2019

did_any_fail = True
if test_result.stderr:
# NB: we write to stdout, rather than to stderr, to avoid potential issues interleaving the
# two streams.

This comment has been minimized.

Copy link
@stuhood

stuhood May 9, 2019

Member

Yep, writing to stdout here makes sense I think.

@Eric-Arellano Eric-Arellano merged commit c0bfc9e into pantsbuild:master May 10, 2019

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@Eric-Arellano Eric-Arellano deleted the Eric-Arellano:v2-pytest-stderr branch May 10, 2019

Eric-Arellano added a commit to Eric-Arellano/pants that referenced this pull request May 10, 2019

Squashed commit of the following:
commit 0a38b338ba5c3d9dd0bc080fa477e8b74e9850e6
Merge: c0bfc9e 9ca32a9
Author: Eric Arellano <ericarellano@me.com>
Date:   Fri May 10 11:20:51 2019 -0700

    Merge branch 'dwagnerhall/strip-prefix' of https://github.com/twitter/pants into twitter-dwagnerhall/strip-prefix

commit c0bfc9e
Author: Eric Arellano <ericarellano@me.com>
Date:   Fri May 10 10:49:18 2019 -0700

    Output stderr in V2 test rule (pantsbuild#7694)

    ### Problem
    Implements pantsbuild#7388. Swallowing stderr makes debugging very difficult.

    Important clarification: failing tests will write to stdout, meaning that we do already output any message captured by Pytest. Instead, this PR is meant to log issues that occur before Pytest executes, such as issues from Pants.

    ### Solution
    Follow the convention established by pantsbuild#7676 to output `{address} stderr:`, followed by the stderr.

commit 55e5721
Author: Daniel Wagner-Hall <dwagnerhall@twitter.com>
Date:   Fri May 10 17:32:03 2019 +0100

    Remove now-unused Path type (pantsbuild#7701)

    The engine lost Paths from its Snapshots at some point, and we didn't clean up.

commit 9ca32a9
Author: Daniel Wagner-Hall <dwagnerhall@twitter.com>
Date:   Fri May 10 10:59:41 2019 +0100

    Allow Directories to be un-nested

commit 5eed2e7
Author: Eric Arellano <ericarellano@me.com>
Date:   Thu May 9 17:38:03 2019 -0700

    Mark build-support Python files as Pants targets to lint build-support (pantsbuild#7633)

    ### Converting to Pants targets
    Now that we have two Python scripts, and may have more scripts in the future, there is value in linting our script code.

    By making these two scripts as targets, we can now use `./pants fmt`, `./pants lint`, and `./pants mypy` on the build-support folder for little cost.

    The pre-commit check will check `./pants fmt` and `./pants lint` automatically on the `build-support` Python files now. It will not do the header check until we explicitly add the folder.

    ### Add `common.py`
    We also add `common.py` to reduce duplication and simplify writing scripts.

    See the `NB` in that file about why we only use the stdlib for that file.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.