lib/autoproj/cli/test.rb in autoproj-1.13.7 vs lib/autoproj/cli/test.rb in autoproj-2.0.0.b1

- old
+ new

@@ -1,69 +1,50 @@ -require 'autoproj/ops/tools' +require 'autoproj/cli/inspection_tool' module Autoproj module CLI - class Test - include Ops::Tools - - attr_reader :manifest - - def initialize(manifest) - @manifest = manifest + class Test < InspectionTool + def enable(user_selection, options = Hash.new) + if user_selection.empty? + ws.load_config + ws.config.utility_enable_all('test') + else + initialize_and_load + selection, _ = finalize_setup( + user_selection, + recursive: options[:deps], + ignore_non_imported_packages: true) + ws.config.utility_enable('test', *selection) + end + ws.config.save end - def parse_options(args) - Autoproj.load_config - - modified_config = false - mode = nil - options = Hash.new - option_parser = OptionParser.new do |opt| - opt.on '--enable[=PACKAGE,PACKAGE]', Array, 'enable tests for all packages or for specific packages (does not run the tests)' do |packages| - if !packages - Autoproj.config.utility_enable_all('test') - else - Autoproj.config.utility_enable_for('test', *packages) - end - modified_config = true - end - opt.on '--disable[=PACKAGE,PACKAGE]', Array, 'disable tests for all packages or for specific packages (does not run the tests)' do |packages| - if !packages - Autoproj.config.utility_disable_all('test') - else - Autoproj.config.utility_disable_for('test', *packages) - end - modified_config = true - end - opt.on '--list', 'list the test availability and enabled/disabled state information' do - mode = 'list' - end - opt.on '--[no-]recursion', '(do not) run or list the tests of the dependencies of the packages given on the command line (the default is false)' do |flag| - options[:recursive] = flag - end + def disable(user_selection, options = Hash.new) + if user_selection.empty? + ws.load_config + ws.config.utility_disable_all('test') + else + initialize_and_load + selection, _ = finalize_setup( + user_selection, + recursive: options[:deps], + ignore_non_imported_packages: true) + ws.config.utility_disable('test', *selection) end - - user_selection = option_parser.parse(ARGV) - if !mode && !(modified_config && user_selection.empty?) - mode = 'run' - end - - if modified_config - Autoproj.save_config - end - return mode, user_selection, options + ws.config.save end def list(user_selection, options = Hash.new) - resolved_selection = resolve_selection( + initialize_and_load + resolved_selection, _ = finalize_setup( user_selection, - recursive: options[:recursive], + recursive: options[:dep], ignore_non_imported_packages: true) lines = Array.new resolved_selection.each do |pkg_name| - pkg = manifest.find_package(pkg_name).autobuild + pkg = ws.manifest.find_package(pkg_name).autobuild lines << [pkg.name, pkg.test_utility.enabled?, pkg.test_utility.available?] end lines = lines.sort_by { |name, _| name } w = lines.map { |name, _| name.length }.max format = "%-#{w}s %-7s %-9s" @@ -72,14 +53,12 @@ puts(format % [name, (!!enabled).to_s, (!!available).to_s]) end end def run(user_selection, options = Hash.new) - packages = resolve_selection( - user_selection, - recursive: options[:recursive], - ignore_non_imported_packages: true) - # This calls #prepare, which is required to run build_packages + initialize_and_load + packages, _ = finalize_setup(user_selection) + packages.each do |pkg| Autobuild::Package[pkg].disable_phases('import', 'prepare', 'install') end Autobuild.apply(packages, "autoproj-test", ['test']) end