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

Add new ParallelTests::RSpec::VerboseFormatter for enhanced debugging #926

Merged
merged 1 commit into from
Dec 24, 2023

Commits on Dec 24, 2023

  1. Add new ParallelTests::RSpec::VerboseFormatter for enhanced debugging

    The new formatter allows users of parallel_rspec to more easily obtain
    detailed information about the examples running as they occur in real
    time.
    
    Background:
    
    In my project, it was observed that an RSpec example would hang
    intermittently on CI. At first, no team member was able to make this
    reliably fail enough on CI to facilitate debugging and no one was able
    to reproduce locally at all. The hang only occurred with parallel tests
    running and never with just the "rspec" command.
    
    In an attempt to gather more information, we began using the RSpec
    "documentation" formatter which outputs the "description", "context",
    and "it" strings. Unfortunately, when running in parallel, the output
    from different processes will interleave with one another making it
    extremely difficult to understand which example is responsible for the
    observed hang.
    
    Solution:
    
    Build a "documentation-like" formatter that plays nicely with the
    parallel_tests framework. The new formatter always ouputs all
    information on a single line to avoid important details from different
    processes interleaving with one another. This means the "describe" and
    "context" strings will be repeated across multiple "it" blocks.
    
    To further assist, the formatter include the PID and parallel process
    number to help identify which subprocess hangs and which one continues.
    The output will look something like:
    
    ```
    [14403] [2] [STARTED] Foo foo
    [14402] [1] [STARTED] Bar bar
    [14402] [1] [PASSED] Bar bar
    ```
    
    In the output above, it is clear the "Foo foo" example is still running.
    
    Using this formatter, our project's team was able to successfully
    identify the example causing the intermittent hang and then address it.
    As such, I'm hoping that this may be useful for a larger audience.
    jdufresne committed Dec 24, 2023
    Configuration menu
    Copy the full SHA
    ae0fcd7 View commit details
    Browse the repository at this point in the history