This commit is contained in:
Ed Reel
2024-09-11 12:33:24 -05:00
committed by GitHub
parent 7325468db2
commit 679c419673
8 changed files with 44 additions and 28 deletions

View File

@@ -94,6 +94,7 @@ Where available commands are:
| remove | remove package(s) | | remove | remove package(s) |
| search | look for package(s) | | search | look for package(s) |
| sysinfo | show system information in markdown style | | sysinfo | show system information in markdown style |
| test | test crew command(s) |
| update | update crew itself | | update | update crew itself |
| upgrade | update all or specific package(s) | | upgrade | update all or specific package(s) |
| upload | upload binaries for all or specific package(s) | | upload | upload binaries for all or specific package(s) |

View File

@@ -1,24 +0,0 @@
# The default action tests commands and libraries.
task default: %w[command_test lib_test]
# Command tests
task :command_test do
ruby 'tests/commands/const.rb'
ruby 'tests/commands/help.rb'
ruby 'tests/commands/list.rb'
ruby 'tests/commands/prop.rb'
ruby 'tests/commands/remove.rb'
ruby 'tests/commands/whatprovides.rb'
end
# Library tests
task :lib_test do
ruby 'tests/lib/docopt.rb'
ruby 'tests/lib/package_utils.rb'
end
# Package tests
task :package_test do
ruby 'tests/prop_test'
ruby 'tests/buildsystem_test'
end

View File

@@ -1756,6 +1756,30 @@ def sysinfo_command(_args)
Command.sysinfo(CREW_VERBOSE) Command.sysinfo(CREW_VERBOSE)
end end
def test_command(args)
test_commands_path = "#{CREW_LIB_PATH}/tests/commands"
if args['<name>'].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['<name>'].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) def update_command(args)
if args['<compatible>'] if args['<compatible>']
generate_compatible generate_compatible

View File

@@ -118,6 +118,14 @@ class Command
Usage: crew sysinfo [-v|--verbose] Usage: crew sysinfo [-v|--verbose]
If `-v` or `--verbose` is present, show system information with raw markdown. If `-v` or `--verbose` is present, show system information with raw markdown.
EOT EOT
when 'test'
puts <<~EOT
Test crew command(s).
Usage: crew test [<command1> <command2> ...]
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' when 'update'
puts <<~EOT puts <<~EOT
Update crew. Update crew.

View File

@@ -3,7 +3,7 @@
require 'etc' require 'etc'
OLD_CREW_VERSION ||= defined?(CREW_VERSION) ? CREW_VERSION : '1.0' OLD_CREW_VERSION ||= defined?(CREW_VERSION) ? CREW_VERSION : '1.0'
CREW_VERSION ||= '1.52.2' unless defined?(CREW_VERSION) && CREW_VERSION == OLD_CREW_VERSION CREW_VERSION ||= '1.52.1' unless defined?(CREW_VERSION) && CREW_VERSION == OLD_CREW_VERSION
# Kernel architecture. # Kernel architecture.
KERN_ARCH ||= Etc.uname[:machine] KERN_ARCH ||= Etc.uname[:machine]
@@ -332,6 +332,7 @@ CREW_DOCOPT ||= <<~DOCOPT
crew remove [options] [-v|--verbose] <name> ... crew remove [options] [-v|--verbose] <name> ...
crew search [options] [-v|--verbose] <name> ... crew search [options] [-v|--verbose] <name> ...
crew sysinfo [options] [-v|--verbose] crew sysinfo [options] [-v|--verbose]
crew test [options] [-v|--verbose] [<name> ...]
crew update [options] [-v|--verbose] [<compatible>] crew update [options] [-v|--verbose] [<compatible>]
crew upgrade [options] [-k|--keep] [-s|--source] [-v|--verbose] [<name> ...] crew upgrade [options] [-k|--keep] [-s|--source] [-v|--verbose] [<name> ...]
crew upload [options] [-v|--verbose] [<name> ...] crew upload [options] [-v|--verbose] [<name> ...]

View File

@@ -79,7 +79,7 @@ class PackageUtils
pkg_version.gsub!(/-perl5\.\d{2}/, '') pkg_version.gsub!(/-perl5\.\d{2}/, '')
# Delete -llvm18, futureproofed until llvm 100 # Delete -llvm18, futureproofed until llvm 100
pkg_version.gsub!(/-llvm\d{2}/, '') pkg_version.gsub!(/-llvm\d{2}/, '')
# Delete -glibc2.37, or whatever the system glibc is. # Delete -glibc2.39, or whatever the system glibc is.
pkg_version.delete_suffix!("-glibc#{LIBC_VERSION}") pkg_version.delete_suffix!("-glibc#{LIBC_VERSION}")
# Delete git version tags (1.2.4-qnd73k6), avoiding overmatching and hitting things that arent git hashtags. # Delete git version tags (1.2.4-qnd73k6), avoiding overmatching and hitting things that arent git hashtags.
pkg_version.gsub!(/-[\w]{7}$/, '') pkg_version.gsub!(/-[\w]{7}$/, '')

View File

@@ -157,7 +157,7 @@ class PackageUtilsTest < Minitest::Test
end end
def test_get_clean_glibc_version def test_get_clean_glibc_version
assert_equal('9.5.18', PackageUtils.get_clean_version("9.5.18-glibc#{LIBC_VERSION}")) assert_equal('9.5.18', PackageUtils.get_clean_version('9.5.18-glibc2.39'))
end end
def test_get_clean_git_version def test_get_clean_git_version

View File

@@ -10,7 +10,13 @@ git clone --depth=1 --branch="$CREW_BRANCH" "$CREW_REPO" ~/build_test
(cd ~/build_test && yes | CREW_CACHE_ENABLED=1 crew build -vf ~/build_test/packages/hello_world_chromebrew.rb) (cd ~/build_test && yes | CREW_CACHE_ENABLED=1 crew build -vf ~/build_test/packages/hello_world_chromebrew.rb)
yes | crew install vim yes | crew install vim
yes | crew remove vim yes | crew remove vim
rake -C.. ruby ../tests/commands/const.rb
ruby ../tests/commands/help.rb
ruby ../tests/commands/list.rb
ruby ../tests/commands/prop.rb
ruby ../tests/commands/remove.rb
ruby ../tests/commands/whatprovides.rb
ruby ../tests/lib/docopt.rb
if [[ -n ${CHANGED_PACKAGES-} ]]; then if [[ -n ${CHANGED_PACKAGES-} ]]; then
all_compatible_packages=$(crew list -d compatible) all_compatible_packages=$(crew list -d compatible)
all_installed_packages=$(crew list -d installed) all_installed_packages=$(crew list -d installed)