Skip to content

Make it easier to run test files from the command line #635

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

Merged
merged 1 commit into from
Mar 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ In order to ensure high quality, all pull requests must meet these requirements:
While working on specific features you can run individual test files or
a group of tests using `bin/test`:

# run a single file:
$ bin/test tests/units/test_object.rb
# run a single file (from tests/units):
$ bin/test test_object

# run multiple files:
$ bin/test tests/units/test_object.rb tests/units/test_archive.rb
$ bin/test test_object test_archive

# run all unit tests:
$ bin/test
Expand Down
11 changes: 6 additions & 5 deletions bin/test
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ project_root = File.expand_path(File.join(__dir__, '..'))

$LOAD_PATH.unshift(File.join(project_root, 'tests'))

if ARGV.empty?
paths = Dir.glob(File.join(project_root, 'tests/**/test_*.rb'))
else
paths = ARGV.map { |p| File.join(project_root, p) }
end
paths =
if ARGV.empty?
Dir.glob('tests/units/test_*.rb').map { |p| File.basename(p) }
else
ARGV
end.map { |p| File.join(project_root, 'tests/units', p) }

paths.each { |p| require p }