Skip to content

Commit 4eaf514

Browse files
author
Simon Coffey
committed
Extract test runner executable
1 parent 1367dd7 commit 4eaf514

File tree

3 files changed

+37
-10
lines changed

3 files changed

+37
-10
lines changed

CONTRIBUTING.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,18 @@ In order to ensure high quality, all pull requests must meet these requirements:
8181
* The entire test suite must pass when `bundle exec rake default` is run from the
8282
project's local working copy.
8383

84+
While working on specific features you can run individual test files or
85+
a group of tests using `bin/test`:
86+
87+
# run a single file:
88+
$ bin/test tests/units/test_object.rb
89+
90+
# run multiple files:
91+
$ bin/test tests/units/test_object.rb tests/units/test_archive.rb
92+
93+
# run all unit tests:
94+
$ bin/test
95+
8496
### Continuous integration
8597
* All tests must pass in the project's [GitHub Continuous Integration build](https://github.com/ruby-git/ruby-git/actions?query=workflow%3ACI)
8698
before the pull request will be merged.

Rakefile

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,14 @@ default_tasks = []
77

88
desc 'Run Unit Tests'
99
task :test do
10-
sh 'git config --global user.email "git@example.com"' if `git config user.email`.empty?
11-
sh 'git config --global user.name "GitExample"' if `git config user.name`.empty?
10+
sh 'bin/test'
1211

13-
$LOAD_PATH.unshift(File.join(__dir__, 'tests'))
14-
15-
Dir.glob(File.join(__dir__, 'tests/**/test_*.rb')) do |p|
16-
require p
17-
end
18-
19-
# You can run individual test files from the command line with:
12+
# You can run individual test files (or multiple files) from the command
13+
# line with:
14+
#
15+
# $ bin/test tests/units/test_archive.rb
2016
#
21-
# $ ruby -Ilib:tests tests/units/test_archive.rb
17+
# $ bin/test tests/units/test_archive.rb tests/units/test_object.rb
2218
end
2319
default_tasks << :test
2420

bin/test

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
3+
4+
require 'bundler/setup'
5+
6+
`git config --global user.email "git@example.com"` if `git config user.email`.empty?
7+
`git config --global user.name "GitExample"` if `git config user.name`.empty?
8+
9+
project_root = File.expand_path(File.join(__dir__, '..'))
10+
11+
$LOAD_PATH.unshift(File.join(project_root, 'tests'))
12+
13+
if ARGV.empty?
14+
paths = Dir.glob(File.join(project_root, 'tests/**/test_*.rb'))
15+
else
16+
paths = ARGV.map { |p| File.join(project_root, p) }
17+
end
18+
19+
paths.each { |p| require p }

0 commit comments

Comments
 (0)