Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow for duplicate tests with --allow-duplicates (#940)
* 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 * Update lib/parallel_tests/test/runner.rb Co-authored-by: Michael Grosser <[email protected]> * Rubocop cleanup --------- Co-authored-by: Michael Grosser <[email protected]>
- Loading branch information