diff --git a/README.md b/README.md index 9c7de8eef..efac9082d 100644 --- a/README.md +++ b/README.md @@ -93,6 +93,7 @@ Where available commands are: | remove | remove package(s) | | search | look for package(s) | | sysinfo | show system information in markdown style | +| test | test crew command(s) | | update | update crew itself | | upgrade | update all or specific package(s) | | upload | upload binaries for all or specific package(s) | diff --git a/bin/crew b/bin/crew index 22e481f32..4be43c6b8 100755 --- a/bin/crew +++ b/bin/crew @@ -54,6 +54,7 @@ DOC = <<~DOCOPT crew remove [options] ... crew search [options] [ ...] crew sysinfo [options] + crew test [ ...] crew update [options] [] crew upgrade [options] [-k|--keep] [-s|--source] [ ...] crew upload [options] [ ...] @@ -2062,6 +2063,30 @@ def sysinfo_command(_args) end end +def test_command(args) + test_commands_path = "#{CREW_LIB_PATH}/tests/commands" + if args[''].empty? + Dir["#{test_commands_path}/*.rb"].each do |name| + basename = File.basename(name, '.rb') + puts "Testing #{basename} command ...".yellow + system("ruby #{name}") + end + else + args[''].each do |name| + basename = File.basename(name, '.rb') + name = basename if basename != name + if File.file?("#{test_commands_path}/#{name}.rb") + Dir.chdir(test_commands_path) do + puts "Testing #{name} command ...".yellow + system("ruby #{name}.rb") + end + else + puts "The #{name} command or test does not exist. Test skipped.".orange + end + end + end +end + def update_command(args) if args[''] generate_compatible diff --git a/commands/help.rb b/commands/help.rb index b957fcbca..7efb40a30 100644 --- a/commands/help.rb +++ b/commands/help.rb @@ -106,6 +106,14 @@ class Command Usage: crew sysinfo If `-v` or `--verbose` is present, show system information with raw markdown. EOT + when 'test' + puts <<~EOT + Test crew command(s). + Usage: crew test [ ...] + The crew command and associated test must exist. + If no commands are provided, all commands will be tested. + To list all commands, simply type 'crew'. + EOT when 'update' puts <<~EOT Update crew. diff --git a/lib/const.rb b/lib/const.rb index 4238d75e2..0c3f2f236 100644 --- a/lib/const.rb +++ b/lib/const.rb @@ -1,7 +1,7 @@ # lib/const.rb # Defines common constants used in different parts of crew -CREW_VERSION = '1.44.7' +CREW_VERSION = '1.44.8' # kernel architecture KERN_ARCH = `uname -m`.chomp