From 55e323a851b9a76062f6e49883d028c7891f2fd4 Mon Sep 17 00:00:00 2001 From: James Couball Date: Wed, 1 Mar 2023 17:03:12 -0800 Subject: [PATCH] Make it easier to run test files from the command line Signed-off-by: James Couball --- CONTRIBUTING.md | 6 +++--- bin/test | 11 ++++++----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c0526f8e..8b9d7bf9 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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 diff --git a/bin/test b/bin/test index 10115417..8024c5ab 100755 --- a/bin/test +++ b/bin/test @@ -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 }