diff --git a/.github/workflows/Unit-Test.yml b/.github/workflows/Unit-Test.yml index 0271615a7..1700cce28 100644 --- a/.github/workflows/Unit-Test.yml +++ b/.github/workflows/Unit-Test.yml @@ -21,6 +21,7 @@ jobs: yes | crew install vim && \ yes | crew remove vim && \ ruby ../tests/prop_test && \ + ruby ../tests/buildsystem_test && \ ruby ../tests/commands/* && \ cd ~ && \ git clone --depth=1 https://github.com/chromebrew/chromebrew.git build_test && \ diff --git a/bin/crew b/bin/crew index 283d9961f..63c14d270 100755 --- a/bin/crew +++ b/bin/crew @@ -1863,6 +1863,7 @@ end def check_command(args) args[''].each do |name| + check_package(name) search name if @opt_version Dir.chdir CREW_PACKAGES_PATH do @@ -1871,6 +1872,7 @@ def check_command(args) else Dir.chdir CREW_PACKAGES_PATH do system "../tests/prop_test #{name}" + system "../tests/buildsystem_test #{name}" end end end diff --git a/lib/const.rb b/lib/const.rb index 61df1a2fe..d317be7a8 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.45.8' +CREW_VERSION = '1.45.9' # kernel architecture KERN_ARCH = `uname -m`.chomp diff --git a/tests/buildsystem_test b/tests/buildsystem_test new file mode 100755 index 000000000..f45ffc7a7 --- /dev/null +++ b/tests/buildsystem_test @@ -0,0 +1,44 @@ +#!/usr/bin/env ruby + +require_relative '../lib/color' + +def get_buildsystems(file, field) + return `grep ^class #{file} | cut -d' ' -f#{field} | xargs`.chomp +end + +def check_buildsystem(name) + puts "Checking #{name} package ...".yellow + buildsystem = get_buildsystems("../packages/#{name}.rb", 4) + if @buildsystems.include?(buildsystem) + puts "Buildsystem test for #{name} passed.".lightgreen + else + puts "#{buildsystem} is an invalid buildsystem. Valid buildsystems include #{@buildsystems.sort.join(', ')}.".lightred + puts "Buildsystem test for #{name} failed.".lightred + @tofail += 1 + end +end + +@tofail = 0 +@buildsystems = "Package #{get_buildsystems('../lib/buildsystems/*.rb', 2)}".split + +if ARGV[0] + ARGV.each do |arg| + if File.file? "../packages/#{arg}.rb" + check_buildsystem(arg) + else + puts "Package #{arg} not found.".lightred + end + end +else + Dir['../packages/*.rb'].each do |filename| + name = File.basename(filename, '.rb') + check_buildsystem(name) + end + + if @tofail.positive? + puts "\n#{@tofail} packages failed buildsystem tests.".lightred + exit(1) + else + puts "\nAll packages passed buildsystem tests.".lightgreen + end +end