Skip to content

Commit

Permalink
Add support for parallel_tests to "geordi unit"
Browse files Browse the repository at this point in the history
  • Loading branch information
martinschaflitzl1 committed Aug 2, 2024
1 parent 160b052 commit 21a7760
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,11 @@ All rspec specs and cucumber features matching the given paths will be run.
### `geordi unit`
Run Test::Unit.

Supports `parallel_tests`, binstubs and `bundle exec`.

In order to limit processes in a parallel run, you can set an environment
variable like this: `PARALLEL_TEST_PROCESSORS=6 geordi unit`


### `geordi update`
Bring a project up to date.
Expand Down
19 changes: 19 additions & 0 deletions features/unit.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Feature: The unit command

Background:
Given a file named "test/test_helper.rb" with "enable unit tests"

Scenario: A rake binstub is used if present
Given a file named "bin/rake" with "binstub"

When I run `geordi unit`
Then the output should contain "Util.run! bin/rake, test"


Scenario: A rake binstub is used to run parallel tests if present
Given a file named "bin/rake" with "binstub"
And a file named "Gemfile" with "gem 'parallel_tests'"

When I run `geordi unit`
Then the output should contain "All unit tests at once (using parallel_tests)"
And the output should contain "Util.run! bin/rake, parallel:test"
14 changes: 13 additions & 1 deletion lib/geordi/commands/unit.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
desc 'unit', 'Run Test::Unit'
long_desc <<-LONGDESC
Supports `parallel_tests`, binstubs and `bundle exec`.
In order to limit processes in a parallel run, you can set an environment
variable like this: `PARALLEL_TEST_PROCESSORS=6 geordi unit`
LONGDESC
def unit
if File.exist?('test/test_helper.rb')
invoke_geordi 'bundle_install'
invoke_geordi 'yarn_install'

Interaction.announce 'Running Test::Unit'
Util.run!([Util.binstub_or_fallback('rake'), 'test'])

if Util.file_containing?('Gemfile', /parallel_tests/)
Interaction.note 'All unit tests at once (using parallel_tests)'
Util.run!([Util.binstub_or_fallback('rake'), 'parallel:test'], fail_message: 'Test::Unit failed.')
else
Util.run!([Util.binstub_or_fallback('rake'), 'test'], fail_message: 'Test::Unit failed.')
end
else
Interaction.note 'Test::Unit not employed.'
end
Expand Down

0 comments on commit 21a7760

Please sign in to comment.