Skip to content

Tests using Cobra with ptytest can hang on macOS (and Windows) unless the output is consumed #2122

@mafredri

Description

@mafredri

Unless ptytest output is consumed, a test can hang if a command outputs more than 1024 bytes (at least on macOS).

There are two ways to work around this issue:

  1. Consume the output via pty.ExpectMatch() (ensure no more than 1024 bytes are left unread)
  2. Use cmd.SetOut(io.Discard) instead

Since using ptytest is a common pattern in our tests, it'd be a good idea to rewrite it so that a hang is not possible.

Unless there's a bug to be fixed in underlying libraries, or changes to how ptys are configured, the most robust way to fix this would be for ptytest to buffer/consume all command output, irregardless of a call to ExpectMatch.

A reproduction of this bug exists as a test in #1629 (and will be merged in and skipped on macOS and Windows).

Metadata

Metadata

Assignees

No one assigned

    Labels

    apiArea: HTTP APIsiteArea: frontend dashboard

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy