From 679c419673b610c56ac028ab3c31ef4f4c6a4af1 Mon Sep 17 00:00:00 2001 From: Ed Reel Date: Wed, 11 Sep 2024 12:33:24 -0500 Subject: [PATCH] Revert #10453 (#10456) --- README.md | 1 + Rakefile | 24 ------------------------ bin/crew | 24 ++++++++++++++++++++++++ commands/help.rb | 8 ++++++++ lib/const.rb | 3 ++- lib/package_utils.rb | 2 +- tests/lib/package_utils.rb | 2 +- tests/unit_test.sh | 8 +++++++- 8 files changed, 44 insertions(+), 28 deletions(-) delete mode 100644 Rakefile diff --git a/README.md b/README.md index 04ab7cf8c..a7e8822e5 100644 --- a/README.md +++ b/README.md @@ -94,6 +94,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/Rakefile b/Rakefile deleted file mode 100644 index 08662aa53..000000000 --- a/Rakefile +++ /dev/null @@ -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 diff --git a/bin/crew b/bin/crew index 67e3a02f3..0292f5d54 100755 --- a/bin/crew +++ b/bin/crew @@ -1756,6 +1756,30 @@ def sysinfo_command(_args) Command.sysinfo(CREW_VERBOSE) 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 f29023622..78f0c0f86 100644 --- a/commands/help.rb +++ b/commands/help.rb @@ -118,6 +118,14 @@ class Command Usage: crew sysinfo [-v|--verbose] 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 e06d61863..6f43652c4 100644 --- a/lib/const.rb +++ b/lib/const.rb @@ -3,7 +3,7 @@ require 'etc' 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. KERN_ARCH ||= Etc.uname[:machine] @@ -332,6 +332,7 @@ CREW_DOCOPT ||= <<~DOCOPT crew remove [options] [-v|--verbose] ... crew search [options] [-v|--verbose] ... crew sysinfo [options] [-v|--verbose] + crew test [options] [-v|--verbose] [ ...] crew update [options] [-v|--verbose] [] crew upgrade [options] [-k|--keep] [-s|--source] [-v|--verbose] [ ...] crew upload [options] [-v|--verbose] [ ...] diff --git a/lib/package_utils.rb b/lib/package_utils.rb index ac22d48c3..986699e4e 100644 --- a/lib/package_utils.rb +++ b/lib/package_utils.rb @@ -79,7 +79,7 @@ class PackageUtils pkg_version.gsub!(/-perl5\.\d{2}/, '') # Delete -llvm18, futureproofed until llvm 100 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}") # Delete git version tags (1.2.4-qnd73k6), avoiding overmatching and hitting things that arent git hashtags. pkg_version.gsub!(/-[\w]{7}$/, '') diff --git a/tests/lib/package_utils.rb b/tests/lib/package_utils.rb index ba86fda67..eb76b0460 100644 --- a/tests/lib/package_utils.rb +++ b/tests/lib/package_utils.rb @@ -157,7 +157,7 @@ class PackageUtilsTest < Minitest::Test end 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 def test_get_clean_git_version diff --git a/tests/unit_test.sh b/tests/unit_test.sh index 0201515d0..f64f26f19 100755 --- a/tests/unit_test.sh +++ b/tests/unit_test.sh @@ -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) yes | crew install 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 all_compatible_packages=$(crew list -d compatible) all_installed_packages=$(crew list -d installed)