Skip to content

Improve the RSpec Queue Mode runner log output (add seed)#178

Merged
shadre merged 1 commit intomasterfrom
improve-log-output
Oct 13, 2022
Merged

Improve the RSpec Queue Mode runner log output (add seed)#178
shadre merged 1 commit intomasterfrom
improve-log-output

Conversation

@shadre
Copy link
Copy Markdown
Member

@shadre shadre commented Sep 27, 2022

No description provided.

@shadre shadre added the wip Work in progress label Sep 27, 2022
@shadre shadre force-pushed the improve-log-output branch 7 times, most recently from 76ca411 to 6fde7dd Compare September 29, 2022 15:47
@shadre shadre changed the title wip Improve the RSpec Queue Mode runner log output (add seed) Sep 29, 2022
Comment thread lib/knapsack_pro/runners/queue/rspec_runner.rb
@shadre shadre removed the wip Work in progress label Sep 29, 2022
@shadre shadre requested a review from ArturT September 29, 2022 15:51
Copy link
Copy Markdown
Member

@ArturT ArturT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked the code and left some minor comments.

I'm going to do manual testing and then I will do the final code review.

Comment thread CHANGELOG.md
Comment thread lib/knapsack_pro/runners/queue/rspec_runner.rb Outdated
@shadre shadre force-pushed the improve-log-output branch 2 times, most recently from 78f35ed to b84a3db Compare October 3, 2022 15:44
Comment thread lib/knapsack_pro/runners/queue/rspec_runner.rb
Copy link
Copy Markdown
Member

@ArturT ArturT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I left some minor comments on what could be improved. It's up to you.

While I was manually testing these changes, I added bin scripts that I was using for testing. Here is related PR: KnapsackPro/rails-app-with-knapsack_pro#40

@shadre shadre force-pushed the improve-log-output branch 5 times, most recently from 8795fdf to 8b4109a Compare October 12, 2022 16:33
@shadre shadre requested a review from ArturT October 12, 2022 16:33
it { expect(subject).to eq 'random' }

context 'with the seed' do
let(:cli_args) { ['--order', 'rand:123456'] }
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should there be random:123456 instead of 'rand:123456'?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, thanks

Comment thread spec/knapsack_pro/adapters/rspec_adapter_spec.rb

context 'when @@used_seed has been set' do
let(:used_seed) { '8333' }
let(:logged_rspec_command_matcher) { /#{args.join(' ')} --seed #{used_seed} \"#{all_test_file_paths.join(' ')}\"/ }
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sometimes I wonder what to do in a situation like this.
It's easier to use programming in the spec to generate the expected string. I often do it because I like the convenience. But on the other hand, we can make mistakes in the spec as well. Who is going to test the spec itself? - once, a friend asked me :)

I had to put some mental effort into figuring out what we actually expected as a string here. It wasn't clear from reading the code.

I see one potential problem. For now, we assume let(:all_test_file_paths) { ['a_spec.rb'] } has one spec only.
If there would be more specs, then the \"#{all_test_file_paths.join(' ')}\" code does not generate a string that we actually should expect. Each spec file should be inside of apostrophes. For example, for 2 specs it should be "a_spec.rb" "b_spec.rb". It's needed to ensure RSpec can run spec files from a directory with a space in the name.
Currently your coude would generated incorrect string "a_spec.rb b_spec.rb".

You may consider using the expected string explicitly here so that reading the code is easier.
But I'm leaving it up to you. Whatever you prefer, it's fine with me.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. I'm changing this to simply include a literal path in the expectation.

Copy link
Copy Markdown
Member

@ArturT ArturT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left two potential improvement suggestions. @shadre Up to you.

@shadre shadre force-pushed the improve-log-output branch from 8b4109a to ae9de7d Compare October 13, 2022 11:35
@shadre shadre merged commit 06609b9 into master Oct 13, 2022
@shadre shadre deleted the improve-log-output branch October 13, 2022 11:44
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

Successfully merging this pull request may close these issues.

2 participants