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

Allow for duplicate tests with --allow-duplicates #940

Merged
merged 3 commits into from
Mar 25, 2024

Commits on Mar 22, 2024

  1. Allow for duplicate tests to run

    > tldr; It's useful to run 1 or more tests multiple times when debugging
    and I'd like to propose an option to do so with parallel_tests
    
    I often find that I'd like to run 1+ files locally, in parallel, to rule
    out certain flakey test behaviors (order tests are being run). Kind of
    like a form of "test fuzzing" I guess? The purpose is to generally rule
    out the test is flakey.
    
    I often find myself doing something like this in zsh:
    
        repeat 10 bin/rspec path/to/my_spec.rb
    
    Sometimes it's more than 10, and sometimes it's more than 1 file I'd
    like to run at the same time.
    
    I'd like to do this with parallel_tests instead and I'd like to propose
    this PR as a potential solution (I didn't see this functionality present
    with the current options)
    
    Example usage:
    
    ```
    export TEST_FILES="
    spec/test_1.rb
    spec/test_1.rb
    spec/test_1.rb
    spec/test_1.rb
    spec/test_1.rb
    "
    
    bin/spring parallel_rspec -n 5 --allow-duplicates -- $(echo $TEST_FILES)
    
    bin/spring parallel_rspec -n 5 -- $(echo $TEST_FILES)
    ```
    
    There's one _minor_ caveat:
    
    These duplicates will still be unique per process because RSpec _also_
    calls uniq in a couple places
    
    [here](https://github.com/rspec/rspec-core/blob/1e661db5c5b431c0ee88a383e8e3767f02dccbfe/lib/rspec/core/configuration.rb#L2202), [here](https://github.com/rspec/rspec-core/blob/1e661db5c5b431c0ee88a383e8e3767f02dccbfe/lib/rspec/core/configuration.rb#L2222), and [here](https://github.com/rspec/rspec-core/blob/1e661db5c5b431c0ee88a383e8e3767f02dccbfe/lib/rspec/core/configuration.rb#L1636)
    
    If there is interest in this PR, I'd be happy to propose a similar
    PR to the RSpec team.
    
    One other thought: I was also thinking a companion `--repeat <Integer>`
    flag could be useful, where it multiplies the file list N times
    and then builds the commands.
    
        bin/spring parallel_rspec --repeat 100 -- path/to/my_spec.rb
    
    Would happy to hear any thoughts or opinions on that as well. I'd
    be happy to do a separate PR
    jaydorsey committed Mar 22, 2024
    Configuration menu
    Copy the full SHA
    827320b View commit details
    Browse the repository at this point in the history

Commits on Mar 25, 2024

  1. Update lib/parallel_tests/test/runner.rb

    Co-authored-by: Michael Grosser <michael@grosser.it>
    jaydorsey and grosser committed Mar 25, 2024
    Configuration menu
    Copy the full SHA
    1b7f761 View commit details
    Browse the repository at this point in the history
  2. Rubocop cleanup

    jaydorsey committed Mar 25, 2024
    Configuration menu
    Copy the full SHA
    fbfbb3b View commit details
    Browse the repository at this point in the history