diff --git a/README.md b/README.md index 3540b53..1af6530 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/features/unit.feature b/features/unit.feature new file mode 100644 index 0000000..e531538 --- /dev/null +++ b/features/unit.feature @@ -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" diff --git a/lib/geordi/commands/unit.rb b/lib/geordi/commands/unit.rb index a5278bb..4bc29d4 100644 --- a/lib/geordi/commands/unit.rb +++ b/lib/geordi/commands/unit.rb @@ -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