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

When executing with bundle exec rake parallel:spec and specifying a folder, unnecessary specs also get executed. #912

Open
yokei-dev opened this issue Aug 15, 2023 · 1 comment

Comments

@yokei-dev
Copy link

yokei-dev commented Aug 15, 2023

Hello!

Summary

When executing with bundle exec rake parallel:spec and specifying a folder, unnecessary specs also get executed.

Steps to Reproduce

Conditions

We have our specs in a file structure that looks like this.
We want execute spec files only in target_folder.

project_root/
    spec/
        non_target_spec.rb
    target_folder/
        spec/
            target_spec.rb

Executed command

bundle exec rake parallel:spec['spec','-- target_folder']

Expected Behavior

spec files only in target_folder are executed

Actual Behavior

spec files are executed, including non_target_spec.rb

My opinion

I understand this problem can avoid by using other command.
That's it #434
bundle exec parallel_rspec target_folder

I'm considering making changes because unnecessary operations might be causing this issue.
https://github.com/grosser/parallel_tests/blob/master/lib/parallel_tests/tasks.rb#L120
I want suggest like this.

diff --git a/lib/parallel_tests/tasks.rb b/lib/parallel_tests/tasks.rb
index efda5cd..a22fcfb 100644
--- a/lib/parallel_tests/tasks.rb
+++ b/lib/parallel_tests/tasks.rb
@@ -117,7 +117,7 @@ module ParallelTests
         executable = ParallelTests.with_ruby_binary(executable)
 
-        command = [*executable, type, '--type', test_framework]
+        command = [*executable, '--type', test_framework]
         command += ['-n', count.to_s] if count

I track the process when executed bundle exec rake parallel:spec['spec','-- target_folder'].

In this case, the type variable contains the string value "spec".
It hasn't been specified with options like -n or -p, so when executing OptionParse, "spec" strings remain in the args.
https://github.com/grosser/parallel_tests/blob/master/lib/parallel_tests/cli.rb#L288
and then, in extract_file_paths(argv) method, "spec" is returned unintentionally with "target_folder".
As a result, spec files are executed, including non_target_spec.rb

So, I think type is unnessesary in https://github.com/grosser/parallel_tests/blob/master/lib/parallel_tests/tasks.rb#L120
Even if folder is not specified, spec folder is specified by default_test_folder method. so, i think no problem. https://github.com/grosser/parallel_tests/blob/master/lib/parallel_tests/cli.rb#L300

Please let me know if you have any concerns regarding this change.
If there are no concerns, I'll go ahead and submit a PR!

This is my first time submitting an issue, so I apologize if I said anything odd or out of place.

@grosser
Copy link
Owner

grosser commented Aug 17, 2023

The first argument is not the type but a regex to find files, from readme:

rake parallel:test[user]  # run users_controller + user_helper + user tests

so putting spec there makes it find all files with spec in the name
just don't do that ?

bundle exec rake parallel:spec['target_folder/']

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants