From 8c2fd96caf9ef976d93b7caa29bb5f4982d7ef95 Mon Sep 17 00:00:00 2001 From: Gabriel Arjones Date: Thu, 2 Mar 2023 15:21:42 -0300 Subject: [PATCH] add support for ruby 3 --- .github/workflows/lint.yml | 2 +- .github/workflows/test.yml | 2 +- Gemfile | 2 + autoproj.gemspec | 2 +- lib/autoproj/cli/main_doc.rb | 19 ++++++---- lib/autoproj/cli/main_test.rb | 19 ++++++---- lib/autoproj/cli/utility.rb | 8 ++-- lib/autoproj/ops/cache.rb | 3 +- lib/autoproj/vcs_definition.rb | 1 + test/cli/test_build.rb | 3 +- test/cli/test_doc.rb | 25 ++++++++++++- test/cli/test_status.rb | 3 +- test/cli/test_test.rb | 19 ++++++++++ test/cli/test_update.rb | 14 ++++--- test/ops/test_configuration.rb | 37 +++++++++++++------ test/ops/test_import.rb | 34 ++++++++++------- .../package_managers/test_apt_dpkg_manager.rb | 14 ++++--- test/package_managers/test_bundler_manager.rb | 3 +- test/package_managers/test_gem.rb | 15 +++++--- test/package_managers/test_pip.rb | 3 +- test/repository_managers/test_apt.rb | 4 +- test/test_package_set.rb | 2 +- test/test_workspace.rb | 3 +- 23 files changed, 161 insertions(+), 76 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 1d868331..53cdbf86 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -8,7 +8,7 @@ jobs: strategy: matrix: - ruby-version: ["2.7", "2.6", "2.5"] + ruby-version: ["3.0", "2.7"] steps: - uses: actions/checkout@v2 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f543bc71..75118611 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,7 +8,7 @@ jobs: strategy: matrix: - ruby-version: ["2.7", "2.6", "2.5"] + ruby-version: ["3.0", "2.7"] steps: - uses: actions/checkout@v2 diff --git a/Gemfile b/Gemfile index b278bafb..6577f077 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,7 @@ source "https://rubygems.org" gem "autobuild", git: "https://github.com/rock-core/autobuild", branch: "master" +gem "rubygems-server" unless RUBY_VERSION < "3" group :dev do gem "rubocop", "~> 1.28.0" @@ -14,4 +15,5 @@ group :vscode do gem "ruby-debug-ide", ">= 0.6.0" gem "solargraph" end + gemspec diff --git a/autoproj.gemspec b/autoproj.gemspec index a1abc58b..3bbbd4eb 100644 --- a/autoproj.gemspec +++ b/autoproj.gemspec @@ -39,7 +39,7 @@ Gem::Specification.new do |s| s.add_runtime_dependency "utilrb", "~> 3.0.0", ">= 3.0.0" s.add_runtime_dependency "xdg", "= 2.2.5" s.add_development_dependency "aruba", "~> 2.1.0" - s.add_development_dependency "flexmock", "~> 2.0", ">= 2.0.0" + s.add_development_dependency "flexmock" s.add_development_dependency "minitest", "~> 5.0", ">= 5.0" s.add_development_dependency "simplecov" s.add_development_dependency "timecop" diff --git a/lib/autoproj/cli/main_doc.rb b/lib/autoproj/cli/main_doc.rb index 58518bb1..c3427234 100644 --- a/lib/autoproj/cli/main_doc.rb +++ b/lib/autoproj/cli/main_doc.rb @@ -28,10 +28,11 @@ def report(report_options = Hash.new) desc: "controls whether the dependencies of the packages given on the command line should be enabled as well (the default is not)" def enable(*packages) require "autoproj/cli/doc" + options = self.options.merge(parent_options) report(silent: true) do cli = Doc.new - args = cli.validate_options(packages, options) - cli.enable(*args) + *args, options = cli.validate_options(packages, options) + cli.enable(*args, **options) end end @@ -40,10 +41,11 @@ def enable(*packages) desc: "controls whether the dependencies of the packages given on the command line should be disabled as well (the default is not)" def disable(*packages) require "autoproj/cli/doc" + options = self.options.merge(parent_options) report(silent: true) do cli = Doc.new - args = cli.validate_options(packages, options) - cli.disable(*args) + *args, options = cli.validate_options(packages, options) + cli.disable(*args, **options) end end @@ -52,10 +54,11 @@ def disable(*packages) desc: "controls whether the dependencies of the packages given on the command line should be disabled as well (the default is not)" def list(*packages) require "autoproj/cli/doc" + options = self.options.merge(parent_options) report(silent: true) do cli = Doc.new - args = cli.validate_options(packages, options) - cli.list(*args) + *args, options = cli.validate_options(packages, options) + cli.list(*args, **options) end end @@ -78,8 +81,8 @@ def exec(*packages) report do |extra_options| cli = Doc.new options.delete(:tool) - args = cli.validate_options(packages, options.merge(extra_options)) - cli.run(*args) + *args, options = cli.validate_options(packages, options.merge(extra_options)) + cli.run(*args, **options) end end end diff --git a/lib/autoproj/cli/main_test.rb b/lib/autoproj/cli/main_test.rb index 2d2e0e6b..f7003b2c 100644 --- a/lib/autoproj/cli/main_test.rb +++ b/lib/autoproj/cli/main_test.rb @@ -45,8 +45,9 @@ def enable(*packages) require "autoproj/cli/test" report(silent: true) do cli = Test.new - args = cli.validate_options(packages, options) - cli.enable(*args) + options = self.options.merge(parent_options) + *args, options = cli.validate_options(packages, options) + cli.enable(*args, **options) end end @@ -57,8 +58,9 @@ def disable(*packages) require "autoproj/cli/test" report(silent: true) do cli = Test.new - args = cli.validate_options(packages, options) - cli.disable(*args) + options = self.options.merge(parent_options) + *args, options = cli.validate_options(packages, options) + cli.disable(*args, **options) end end @@ -69,8 +71,9 @@ def list(*packages) require "autoproj/cli/test" report(silent: true) do cli = Test.new - args = cli.validate_options(packages, options) - cli.list(*args) + options = self.options.merge(parent_options) + *args, options = cli.validate_options(packages, options) + cli.list(*args, **options) end end @@ -101,8 +104,8 @@ def exec(*packages) Autobuild.ignore_errors = options.delete(:keep_going) Autobuild::TestUtility.coverage_enabled = options.delete(:coverage) options.delete(:tool) - args = cli.validate_options(packages, options.merge(extra_options)) - cli.run(*args) + *args, options = cli.validate_options(packages, options.merge(extra_options)) + cli.run(*args, **options) end end end diff --git a/lib/autoproj/cli/utility.rb b/lib/autoproj/cli/utility.rb index e062600b..b04786a5 100644 --- a/lib/autoproj/cli/utility.rb +++ b/lib/autoproj/cli/utility.rb @@ -17,7 +17,7 @@ def default(enabled) ws.config.save end - def enable(user_selection, options = {}) + def enable(user_selection, **options) if user_selection.empty? ws.load_config ws.config.utility_enable_all(utility_name) @@ -33,7 +33,7 @@ def enable(user_selection, options = {}) ws.config.save end - def disable(user_selection, options = {}) + def disable(user_selection, **options) if user_selection.empty? ws.load_config ws.config.utility_disable_all(utility_name) @@ -49,7 +49,7 @@ def disable(user_selection, options = {}) ws.config.save end - def list(user_selection, options = {}) + def list(user_selection, **options) initialize_and_load resolved_selection, = finalize_setup( user_selection, @@ -75,7 +75,7 @@ def list(user_selection, options = {}) end end - def run(user_selection, options = {}) + def run(user_selection, **options) options[:parallel] ||= ws.config.parallel_build_level initialize_and_load diff --git a/lib/autoproj/ops/cache.rb b/lib/autoproj/ops/cache.rb index 750776a5..aa70da93 100644 --- a/lib/autoproj/ops/cache.rb +++ b/lib/autoproj/ops/cache.rb @@ -164,7 +164,8 @@ def create_or_update_gems(keep_going: true, compile_force: false, compile: []) platform_suffix = "-#{Gem::Platform.local}.gem" failed = [] - compile.each do |gem_name, artifacts: []| + compile.each do |gem_name, options = {}| + artifacts = options[:artifacts] || [] Dir.glob(File.join(cache_dir, "#{gem_name}*.gem")) do |gem| next if gem.end_with?(platform_suffix) diff --git a/lib/autoproj/vcs_definition.rb b/lib/autoproj/vcs_definition.rb index c092eb0f..c925ea66 100644 --- a/lib/autoproj/vcs_definition.rb +++ b/lib/autoproj/vcs_definition.rb @@ -202,6 +202,7 @@ def self.raw_spec_to_s(spec) # @raise ArgumentError if the raw specification does not match an # expected format def self.from_raw(spec, from: nil, raw: [], history: []) + # spec = spec_str || spec_hash normalized_spec = normalize_vcs_hash(spec) unless (type = normalized_spec.delete(:type)) raise ArgumentError, diff --git a/test/cli/test_build.rb b/test/cli/test_build.rb index 060c7c64..f75b07c7 100644 --- a/test/cli/test_build.rb +++ b/test/cli/test_build.rb @@ -21,7 +21,8 @@ module CLI describe "-n" do it "turns dependencies off" do flexmock(Update).new_instances - .should_receive(:run).with([], hsh(deps: false)).once + .should_receive(:run).with([]) + .with_kw_args(hsh(deps: false)).once in_ws do Main.start(["build", "-n", "--silent"]) end diff --git a/test/cli/test_doc.rb b/test/cli/test_doc.rb index f857e359..416a03a7 100644 --- a/test/cli/test_doc.rb +++ b/test/cli/test_doc.rb @@ -24,12 +24,33 @@ module CLI end end + %w[enable disable list exec].each do |subcommand| + describe "--deps" do + it "turns dependencies on" do + meth = subcommand + meth = "run" if subcommand == "exec" + + flexmock(Doc).new_instances + .should_receive(meth.to_sym) + .with(%w[pkg1 pkg2]) + .with_kw_args(hsh(deps: true)) + .once + in_ws do + Main.start(["doc", subcommand, "--deps", "pkg1", "pkg2"]) + end + end + end + end + describe "-n" do it "turns dependencies off" do flexmock(Doc).new_instances - .should_receive(:run).with([], hsh(deps: false)).once + .should_receive(:run) + .with(%w[pkg1 pkg2]) + .with_kw_args(hsh(deps: false)) + .once in_ws do - Main.start(["doc", "-n"]) + Main.start(["doc", "-n", "pkg1", "pkg2"]) end end end diff --git a/test/cli/test_status.rb b/test/cli/test_status.rb index 1b8dbd3e..3bb5cb04 100644 --- a/test/cli/test_status.rb +++ b/test/cli/test_status.rb @@ -15,7 +15,8 @@ module CLI describe "-n" do it "turns dependencies off" do flexmock(Status).new_instances - .should_receive(:run).with([], hsh(deps: false)).once + .should_receive(:run).with([]) + .with_kw_args(hsh(deps: false)).once in_ws do Main.start(["status", "-n"]) end diff --git a/test/cli/test_test.rb b/test/cli/test_test.rb index 018d64a5..8b95f6e1 100644 --- a/test/cli/test_test.rb +++ b/test/cli/test_test.rb @@ -1,4 +1,5 @@ require "autoproj/test" +require "autoproj/cli/main" require "autoproj/cli/test" require "timecop" @@ -42,6 +43,24 @@ module CLI end end + %w[enable disable list exec].each do |subcommand| + describe "--deps" do + it "turns dependencies on" do + meth = subcommand + meth = "run" if subcommand == "exec" + + flexmock(Test).new_instances + .should_receive(meth.to_sym) + .with(%w[pkg1 pkg2]) + .with_kw_args(hsh(deps: true)) + .once + in_ws do + Main.start(["test", subcommand, "--deps", "pkg1", "pkg2"]) + end + end + end + end + describe "#apply_to_packages" do after do Timecop.return diff --git a/test/cli/test_update.rb b/test/cli/test_update.rb index f28c1f2b..2c845408 100644 --- a/test/cli/test_update.rb +++ b/test/cli/test_update.rb @@ -16,7 +16,8 @@ module CLI describe "-n" do it "turns dependencies off" do flexmock(Update).new_instances - .should_receive(:run).with([], hsh(deps: false)).once + .should_receive(:run).with([]) + .with_kw_args(hsh(deps: false)).once in_ws do Main.start(["update", "-n", "--silent"]) end @@ -189,12 +190,12 @@ module CLI it "updates the configuration in checkout_only mode with config: false" do flexmock(ws).should_receive(:load_package_sets) - .with(hsh(checkout_only: true)).once + .with_kw_args(hsh(checkout_only: true)).once cli.run([], config: false) end it "updates the configuration in checkout_only mode if checkout_only is set" do flexmock(ws).should_receive(:load_package_sets) - .with(hsh(checkout_only: true)).once + .with_kw_args(hsh(checkout_only: true)).once cli.run([], checkout_only: true) end it "properly sets up packages while updating configuration only" do @@ -207,7 +208,8 @@ module CLI it "passes options to the osdep installer for package import" do flexmock(Ops::Import).new_instances .should_receive(:import_packages) - .with(PackageSelection, hsh(checkout_only: true, install_vcs_packages: Hash[install_only: true])) + .with(PackageSelection) + .with_kw_args(hsh(checkout_only: true, install_vcs_packages: Hash[install_only: true])) .once .and_return([[], []]) cli.run([], packages: true, checkout_only: true, osdeps: true) @@ -316,7 +318,7 @@ def mock_package_failure(*errors, **options) flexmock(Ops::Import).new_instances.should_receive(:import_packages) .and_return([[], ["test"]]) flexmock(ws).should_receive(:install_os_packages).once - .with(["test"], Hash) + .with(["test"]).with_any_kw_args assert_raises(pkg_set_failure) do cli.run([], keep_going: true, packages: true, osdeps: true) end @@ -325,7 +327,7 @@ def mock_package_failure(*errors, **options) it "performs osdep import based on the value encoded in the import failure exception if the package import failed" do mock_package_failure(osdep_packages: ["test"]) flexmock(ws).should_receive(:install_os_packages).once - .with(["test"], Hash) + .with(["test"]).with_any_kw_args assert_raises(pkg_failure) do cli.run([], keep_going: true, packages: true, osdeps: true) end diff --git a/test/ops/test_configuration.rb b/test/ops/test_configuration.rb index 1b760d7f..5540f832 100644 --- a/test/ops/test_configuration.rb +++ b/test/ops/test_configuration.rb @@ -10,7 +10,15 @@ module Ops def mock_package_set(name, create: false, **vcs) vcs = VCSDefinition.from_raw(vcs) raw_local_dir = File.join(make_tmpdir, "package_set") - flexmock(PackageSet).should_receive(:name_of).with(any, vcs, any) + + flexmock(PackageSet) + .should_receive(:name_of) + .with(any) + .with_kw_args(**vcs) + .and_return(name) + .by_default + + flexmock(PackageSet).should_receive(:name_of).with(any, vcs, **{}).with_any_kw_args .and_return(name).by_default flexmock(PackageSet).should_receive(:raw_local_dir_of).with(any, vcs) .and_return(raw_local_dir).by_default @@ -169,7 +177,8 @@ def expect_fatal_message(message) test_vcs, = mock_package_set "test", type: "git", url: "/test", create: true ops.should_receive(:update_remote_package_set) - .with(test_vcs, Hash).once.and_raise(e_klass = Class.new(RuntimeError)) + .with(test_vcs, **{}).with_any_kw_args.once + .and_raise(e_klass = Class.new(RuntimeError)) root_package_set = make_root_package_set(test_vcs) assert_raises(e_klass) do @@ -180,7 +189,8 @@ def expect_fatal_message(message) it "passes a failure to checkout" do test_vcs, = mock_package_set "test", type: "git", url: "/test" ops.should_receive(:update_remote_package_set) - .with(test_vcs, Hash).once.and_raise(e_klass = Class.new(RuntimeError)) + .with(test_vcs, **{}).with_any_kw_args.once + .and_raise(e_klass = Class.new(RuntimeError)) root_package_set = make_root_package_set(test_vcs) assert_raises(e_klass) do @@ -198,10 +208,10 @@ def expect_fatal_message(message) "test1", type: "git", url: "/test1", create: true ) ops.should_receive(:update_remote_package_set) - .with(test0_vcs, Hash).once + .with(test0_vcs, **{}).with_any_kw_args.once .and_raise(Interrupt) ops.should_receive(:update_remote_package_set) - .with(test1_vcs, Hash).never + .with(test1_vcs, **{}).with_any_kw_args.never root_package_set = make_root_package_set(test0_vcs, test1_vcs) assert_raises(Interrupt) do @@ -213,7 +223,8 @@ def expect_fatal_message(message) it "still raises if a checkout failed" do test_vcs, = mock_package_set "test", type: "git", url: "/test" ops.should_receive(:update_remote_package_set) - .with(test_vcs, Hash).once.and_raise(e_klass = Class.new(RuntimeError)) + .with(test_vcs, **{}).with_any_kw_args.once + .and_raise(e_klass = Class.new(RuntimeError)) root_package_set = make_root_package_set(test_vcs) assert_raises(e_klass) do @@ -225,11 +236,12 @@ def expect_fatal_message(message) create: true test1_vcs, = mock_package_set "test1", type: "git", url: "/test1", create: true + ops.should_receive(:update_remote_package_set) - .with(test0_vcs, Hash).once + .with(test0_vcs, **{}).with_any_kw_args.once .and_raise(error0 = Class.new(RuntimeError)) ops.should_receive(:update_remote_package_set) - .with(test1_vcs, Hash).once + .with(test1_vcs, **{}).with_any_kw_args.once .and_raise(error1 = Class.new(RuntimeError)) root_package_set = make_root_package_set(test0_vcs, test1_vcs) @@ -342,7 +354,7 @@ def expect_fatal_message(message) it "does call the import if checkout_only is set but the package set is not present" do vcs, raw_local_dir = mock_package_set("test", type: "git", url: "/whatever") ops.should_receive(:update_configuration_repository).once - .with(vcs, "test", raw_local_dir, Hash) + .with(vcs, "test", raw_local_dir).with_any_kw_args ops.update_remote_package_set(vcs, checkout_only: false) end @@ -489,7 +501,7 @@ def expect_fatal_message(message) end it "attempts to update and load the package sets after a main configuration import failure" do ops.should_receive(:update_main_configuration).once - .with(hsh(keep_going: true)).and_return([flexmock]) + .with_kw_args(hsh(keep_going: true)).and_return([flexmock]) ops.should_receive(:update_package_sets).once .pass_thru ops.should_receive(:load_package_set_information).once @@ -508,7 +520,7 @@ def expect_fatal_message(message) it "reports package set update errors" do ops.should_receive(:update_main_configuration).once.and_return([]) ops.should_receive(:update_package_sets).once - .with(hsh(keep_going: true)).and_return([failure = flexmock]) + .with_kw_args(hsh(keep_going: true)).and_return([failure = flexmock]) e = assert_raises(ImportFailed) do ops.update_configuration(keep_going: true) end @@ -600,7 +612,8 @@ def add_version_control(package_name, type: "local", url: package_name, **vcs) it "loads the osdep files" do flexmock(ws.manifest.each_package_set.first) .should_receive(:load_osdeps) - .with(File.join(ws.config_dir, "test.osdeps"), Hash) + .with(File.join(ws.config_dir, "test.osdeps")) + .with_any_kw_args .at_least.once.and_return(osdep = flexmock) flexmock(ws.os_package_resolver) .should_receive(:merge).with(osdep).at_least.once diff --git a/test/ops/test_import.rb b/test/ops/test_import.rb index 9d0dedd2..2f567781 100644 --- a/test/ops/test_import.rb +++ b/test/ops/test_import.rb @@ -299,13 +299,14 @@ def read_report it "installs a missing VCS package" do flexmock(base_cmake.autobuild).should_receive(:import).once flexmock(ws.os_package_installer).should_receive(:install) - .with([:git], Hash).once + .with([:git]).with_any_kw_args.once ops.import_selected_packages(mock_selection(base_cmake)) end it "sets install_only if checkout_only is true" do flexmock(base_cmake.autobuild).should_receive(:import).once flexmock(ws.os_package_installer).should_receive(:install) - .with([:git], hsh(install_only: true)).once + .with([:git]) + .with_kw_args(hsh(install_only: true)).once ops.import_selected_packages(mock_selection(base_cmake), checkout_only: true) end it "queues the package's dependencies after it loaded the manifest" do @@ -376,9 +377,11 @@ def read_report mock_vcs(base_cmake, type: "git", url: "https://github.com") base_cmake.autobuild.srcdir = File.join(ws.root_dir, "package") flexmock(base_cmake.autobuild.importer).should_receive(:import) - .with(base_cmake.autobuild, Hash).once + .with(base_cmake.autobuild) + .with_any_kw_args.once flexmock(ops).should_receive(:post_package_import) - .with(any, any, base_cmake, any, Hash) + .with(any, any, base_cmake, any) + .with_any_kw_args .once ops.import_selected_packages(mock_selection(base_cmake)) end @@ -387,7 +390,8 @@ def read_report FileUtils.mkdir_p(base_cmake.autobuild.srcdir = File.join(ws.root_dir, "package")) base_cmake.autobuild.importer = nil flexmock(ops).should_receive(:post_package_import) - .with(any, any, base_cmake, any, Hash) + .with(any, any, base_cmake, any) + .with_any_kw_args .once ops.import_selected_packages(mock_selection(base_cmake)) end @@ -397,24 +401,26 @@ def read_report mock_vcs(non_interactive, interactive: false) main_thread = Thread.current flexmock(non_interactive.autobuild).should_receive(:import).once.globally.ordered - .with(hsh(allow_interactive: false)) + .with_kw_args(hsh(allow_interactive: false)) .and_return do if Thread.current == main_thread flunk("expected the non-interactive package to be imported outside the main thread") end end flexmock(ops).should_receive(:post_package_import) - .with(any, any, non_interactive, any, Hash) + .with(any, any, non_interactive, any) + .with_any_kw_args .once.globally.ordered flexmock(base_cmake.autobuild).should_receive(:import).once.globally.ordered - .with(hsh(allow_interactive: true)) + .with_kw_args(hsh(allow_interactive: true)) .and_return do if Thread.current != main_thread flunk("expected the interactive package to be imported inside the main thread") end end flexmock(ops).should_receive(:post_package_import) - .with(any, any, base_cmake, any, Hash) + .with(any, any, base_cmake, any) + .with_any_kw_args .once.globally.ordered ops.import_selected_packages(mock_selection(non_interactive, base_cmake)) @@ -424,16 +430,17 @@ def read_report mock_vcs(base_cmake, interactive: false) main_thread = Thread.current flexmock(base_cmake.autobuild).should_receive(:import).once.globally.ordered - .with(hsh(allow_interactive: false)) + .with_kw_args(hsh(allow_interactive: false)) .and_raise(Autobuild::InteractionRequired) flexmock(base_cmake.autobuild).should_receive(:import).once.globally.ordered - .with(hsh(allow_interactive: true)) + .with_kw_args(hsh(allow_interactive: true)) .and_return do assert_equal main_thread, Thread.current, "expected interactive imports to be called in the main thread" end flexmock(ops).should_receive(:post_package_import) - .with(any, any, base_cmake, any, Hash) + .with(any, any, base_cmake, any) + .with_any_kw_args .once.globally.ordered ops.import_selected_packages(mock_selection(base_cmake)) end @@ -471,7 +478,8 @@ def read_report # to determine its internal dependencies it "process post import blocks right after importing a package" do mock_vcs(base_cmake, type: "git", url: "https://github.com") - flexmock(base_cmake.autobuild.importer).should_receive(:import).with(base_cmake.autobuild, Hash).once + flexmock(base_cmake.autobuild.importer).should_receive(:import).with(base_cmake.autobuild) + .with_any_kw_args.once flexmock(ops).should_receive(:process_post_import_blocks).once.with(base_cmake) ops.import_selected_packages(mock_selection(base_cmake)) end diff --git a/test/package_managers/test_apt_dpkg_manager.rb b/test/package_managers/test_apt_dpkg_manager.rb index 92f12dc6..9c28d81b 100644 --- a/test/package_managers/test_apt_dpkg_manager.rb +++ b/test/package_managers/test_apt_dpkg_manager.rb @@ -86,12 +86,14 @@ def test_status_file_parsing_not_there_means_not_installed "apt-get", "install", "-y", "noninstalled-package" ] flexmock(Autobuild).should_receive(:tool_in_path) - .with("sudo", any) + .with("sudo").with_any_kw_args .and_return("/sbin/sudo") flexmock(Autobuild::Subprocess).should_receive(:run) - .with(*expected_args, - env: expected_env, - env_inherit: false) + .with(*expected_args) + .with_kw_args( + env: expected_env, + env_inherit: false + ) @mng.install(%w[noninstalled-package]) end end @@ -124,7 +126,7 @@ def test_status_file_parsing_not_there_means_not_installed .never ShellScriptManager.should_receive(:execute) .with(->(cmd) { cmd.include?("installed-package") }, - any, any, any).once + any, any).with_any_kw_args.once AptDpkgManager .should_receive(:parse_packages_versions) .with(["installed-package"]) @@ -151,7 +153,7 @@ def test_status_file_parsing_not_there_means_not_installed ShellScriptManager .should_receive(:execute) .with(->(cmd) { cmd.include?("noninstalled-package") }, - any, any, any).once + any, any).with_any_kw_args.once @mng.install(["noninstalled-package"], filter_uptodate_packages: true, install_only: true) end diff --git a/test/package_managers/test_bundler_manager.rb b/test/package_managers/test_bundler_manager.rb index 387cb16d..be36b806 100644 --- a/test/package_managers/test_bundler_manager.rb +++ b/test/package_managers/test_bundler_manager.rb @@ -8,7 +8,8 @@ module PackageManagers Autobuild.programs["bundle"] = nil ws = flexmock(dot_autoproj_dir: "/some/path") ws.should_receive(:run) - .with(any, any, "/some/path/bin/bundle", "some", "program", Hash, Proc) + .with(any, any, "/some/path/bin/bundle", "some", "program", Proc) + .with_any_kw_args .once BundlerManager.run_bundler(ws, "some", "program", bundler_version: nil, diff --git a/test/package_managers/test_gem.rb b/test/package_managers/test_gem.rb index 77bf4b13..de40c004 100644 --- a/test/package_managers/test_gem.rb +++ b/test/package_managers/test_gem.rb @@ -105,11 +105,14 @@ def test_install_packages packages = [["pkg0"], ["pkg1", ">= 0.5"], ["pkg2"], ["pkg3", ">= 0.9"]] subprocess.should_receive(:run) - .with(any, any, any, any, "mygem", "install", *default_install_options, "--no-rdoc", "--no-ri", "pkg0", "pkg2", Hash).once + .with(any, any, any, any, "mygem", "install", *default_install_options, "--no-rdoc", "--no-ri", "pkg0", "pkg2") + .with_any_kw_args.once subprocess.should_receive(:run) - .with(any, any, any, any, "mygem", "install", *default_install_options, "--no-rdoc", "--no-ri", "pkg1", "-v", ">= 0.5", Hash).once + .with(any, any, any, any, "mygem", "install", *default_install_options, "--no-rdoc", "--no-ri", "pkg1", "-v", ">= 0.5") + .with_any_kw_args.once subprocess.should_receive(:run) - .with(any, any, any, any, "mygem", "install", *default_install_options, "--no-rdoc", "--no-ri", "pkg3", "-v", ">= 0.9", Hash).once + .with(any, any, any, any, "mygem", "install", *default_install_options, "--no-rdoc", "--no-ri", "pkg3", "-v", ">= 0.9") + .with_any_kw_args.once gem_manager.install(packages) end @@ -119,7 +122,8 @@ def test_install_packages_with_doc subprocess = flexmock(Autobuild::Subprocess) subprocess.should_receive(:run) - .with(any, any, any, any, "mygem", "install", *default_install_options, "pkg0", Hash).once + .with(any, any, any, any, "mygem", "install", *default_install_options, "pkg0") + .with_any_kw_args.once gem_manager.install([["pkg0"]]) end @@ -129,7 +133,8 @@ def test_install_packages_with_prerelease subprocess = flexmock(Autobuild::Subprocess) subprocess.should_receive(:run) - .with(any, any, any, any, "mygem", "install", *default_install_options, "--prerelease", "pkg0", Hash).once + .with(any, any, any, any, "mygem", "install", *default_install_options, "--prerelease", "pkg0") + .with_any_kw_args.once gem_manager.install([["pkg0"]]) end diff --git a/test/package_managers/test_pip.rb b/test/package_managers/test_pip.rb index 8bd701fd..39cbd0df 100644 --- a/test/package_managers/test_pip.rb +++ b/test/package_managers/test_pip.rb @@ -25,7 +25,8 @@ def test_install_packages packages = %w[pkg0 pkg1 pkg2] subprocess.should_receive(:run).explicitly - .with(any, any, "mypip", "install", "--user", "pkg0", "pkg1", "pkg2", any).once + .with(any, any, "mypip", "install", "--user", "pkg0", "pkg1", "pkg2") + .with_any_kw_args.once ws.config.interactive = false pip_manager.install(packages) end diff --git a/test/repository_managers/test_apt.rb b/test/repository_managers/test_apt.rb index 7acf68a3..923db0ff 100644 --- a/test/repository_managers/test_apt.rb +++ b/test/repository_managers/test_apt.rb @@ -69,7 +69,7 @@ module RepositoryManagers "sudo", "tee", File.join(sources_dir, "sources.list"), - on { |opt| opt[:input_streams].first.read == updated_file } + input_streams: on { |f| f.first.read == updated_file } ) assert subject.add_source(line) @@ -85,7 +85,7 @@ module RepositoryManagers "tee", "-a", autoproj_sources, - on { |opt| opt[:input_streams].first.read == "#{line}\n" } + input_streams: on { |f| f.first.read == "#{line}\n" } ) assert subject.add_source(line) diff --git a/test/test_package_set.rb b/test/test_package_set.rb index 3cdf16dc..9182b6a1 100644 --- a/test/test_package_set.rb +++ b/test/test_package_set.rb @@ -145,8 +145,8 @@ module Autoproj "branch" => "test_branch" } ) importer = vcs.create_autobuild_importer - flexmock(importer).should_receive(:respond_to?).with(:repository_id).and_return(false) flexmock(vcs).should_receive(:create_autobuild_importer).and_return(importer) + flexmock(importer).should_receive(:respond_to?).with(:repository_id).and_return(false) package_set = PackageSet.new(ws, vcs, raw_local_dir: "/path/to/set") assert_equal vcs.to_s, package_set.repository_id end diff --git a/test/test_workspace.rb b/test/test_workspace.rb index 9ce3db0d..65d8f9aa 100644 --- a/test/test_workspace.rb +++ b/test/test_workspace.rb @@ -95,7 +95,8 @@ def add_version_control(package_name, type: "local", url: package_name, **vcs) it "loads the osdep files" do flexmock(workspace.manifest.each_package_set.first) - .should_receive(:load_osdeps).with(File.join(test_autoproj_dir, "test.osdeps"), Hash) + .should_receive(:load_osdeps).with(File.join(test_autoproj_dir, "test.osdeps")) + .with_any_kw_args .at_least.once.and_return(osdep = flexmock) flexmock(workspace.os_package_resolver) .should_receive(:merge).with(osdep).at_least.once