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

python -m test -jN: write stderr in stdout to get messages in order #89573

Closed
vstinner opened this issue Oct 8, 2021 · 9 comments
Closed

python -m test -jN: write stderr in stdout to get messages in order #89573

vstinner opened this issue Oct 8, 2021 · 9 comments
Labels
3.11 only security fixes tests Tests in the Lib/test dir

Comments

@vstinner
Copy link
Member

vstinner commented Oct 8, 2021

BPO 45410
Nosy @vstinner
PRs
  • bpo-45410: libregrtest -jN writes stderr into stdout #28819
  • bpo-45410: Add test.support.flush_std_streams() #28885
  • bpo-45410: Enhance libregrtest -W/--verbose3 option #28908
  • bpo-45410: regrtest -W leaves stdout/err FD unchanged #28915
  • bpo-45410: regrtest replaces print_warning.orig_stderr #28926
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2022-04-03.03:51:25.367>
    created_at = <Date 2021-10-08.11:15:36.418>
    labels = ['tests', '3.11']
    title = 'python -m test -jN: write stderr in stdout to get messages in order'
    updated_at = <Date 2022-04-03.03:51:25.367>
    user = 'https://github.com/vstinner'

    bugs.python.org fields:

    activity = <Date 2022-04-03.03:51:25.367>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2022-04-03.03:51:25.367>
    closer = 'vstinner'
    components = ['Tests']
    creation = <Date 2021-10-08.11:15:36.418>
    creator = 'vstinner'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 45410
    keywords = ['patch']
    message_count = 9.0
    messages = ['403467', '403480', '403677', '403686', '403707', '403766', '403781', '403827', '403844']
    nosy_count = 1.0
    nosy_names = ['vstinner']
    pr_nums = ['28819', '28885', '28908', '28915', '28926']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue45410'
    versions = ['Python 3.11']

    @vstinner
    Copy link
    Member Author

    vstinner commented Oct 8, 2021

    In buildbot logs, when a worker process is run, two pipes are created for stdout and stderr. The problem is that using two pipes produce an output which is hard to read.

    Pseudo output:
    ---
    stdout time 1
    stdout time 2
    stdout time 3
    stderr time 1
    stderr time 2
    ---

    I would prefer:
    ---
    stdout time 1
    stderr time 1
    stdout time 2
    stderr time 2
    stdout time 3
    ---

    Real logs:
    https://buildbot.python.org/all/#/builders/79/builds/870
    ---

    0:01:10 load avg: 4.48 [236/427/1] test_ftplib failed (env changed) -- (...)
    Warning -- Uncaught thread exception: Exception
    Exception in thread Thread-67:
    Traceback (most recent call last):
      (...)
    Exception
    test__all__ (test.test_ftplib.MiscTestCase) ... ok
    test_abort (test.test_ftplib.TestFTPClass) ... ok
    test_acct (test.test_ftplib.TestFTPClass) ... ok
    test_all_errors (test.test_ftplib.TestFTPClass) ... ok
    (...)
    Ran 94 tests in 2.326s

    The Warning is logged at the beginning, it's not possible to know which test emitted this warning.

    I propose to write stdout and stderr of a worker process into a single pipe to keep messages order.

    In the past, I saw buildbot logging stderr messages in a different color. But it no longer seems to be the case.

    I'm working on a PR.

    @vstinner vstinner added 3.11 only security fixes tests Tests in the Lib/test dir labels Oct 8, 2021
    @vstinner
    Copy link
    Member Author

    vstinner commented Oct 8, 2021

    New changeset b108db6 by Victor Stinner in branch 'main':
    bpo-45410: libregrtest -jN writes stderr into stdout (GH-28819)
    b108db6

    @vstinner
    Copy link
    Member Author

    Sadly, a recent build failure (at commit 560a79f) still write "Uncaught thread exception" at the top of logs:
    ---
    0:00:11 load avg: 6.07 [315/427/1] test_ftplib failed (env changed)
    Warning -- Uncaught thread exception: Exception
    Exception in thread Thread-67:
    (...)
    Exception
    test__all__ (test.test_ftplib.MiscTestCase) ... ok
    test_abort (test.test_ftplib.TestFTPClass) ... ok
    (...)
    Ran 94 tests in 3.234s
    OK (skipped=1)
    ---

    @vstinner
    Copy link
    Member Author

    New changeset 1ebd798 by Victor Stinner in branch 'main':
    bpo-45410: Add test.support.flush_std_streams() (GH-28885)
    1ebd798

    @vstinner
    Copy link
    Member Author

    Calling sys.stdout doesn't help :-(

    Fail at commit ce3489c:
    https://buildbot.python.org/all/#/builders/73/builds/788
    ---
    0:00:10 load avg: 7.59 [306/427/1] test_ftplib failed (env changed)
    Warning -- Uncaught thread exception: Exception
    Exception in thread Thread-67:
    (...)
    Exception
    test__all__ (test.test_ftplib.MiscTestCase) ... ok
    test_abort (test.test_ftplib.TestFTPClass) ... ok
    test_acct (test.test_ftplib.TestFTPClass) ... ok
    (...)
    ---

    The warning cannot come from MiscTestCase.test__all__(), so the warning is still logged at the wrong place.

    @vstinner
    Copy link
    Member Author

    New changeset dbe213d by Victor Stinner in branch 'main':
    bpo-45410: Enhance libregrtest -W/--verbose3 option (GH-28908)
    dbe213d

    @vstinner
    Copy link
    Member Author

    bpo-45410: Enhance libregrtest -W/--verbose3 option (GH-28908)

    Oh. Sadly, with this change, faulthandler is no longer able to dump a traceback on a crash :-(

    @vstinner
    Copy link
    Member Author

    New changeset 7733307 by Victor Stinner in branch 'main':
    bpo-45410: regrtest -W leaves stdout/err FD unchanged (GH-28915)
    7733307

    @vstinner
    Copy link
    Member Author

    New changeset 676201a by Victor Stinner in branch 'main':
    bpo-45410: regrtest replaces print_warning.orig_stderr (GH-28926)
    676201a

    @vstinner vstinner closed this as completed Apr 3, 2022
    @vstinner vstinner closed this as completed Apr 3, 2022
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.11 only security fixes tests Tests in the Lib/test dir
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant