From 1e3041e05db7584603f3506f234dd340727158c3 Mon Sep 17 00:00:00 2001 From: Gabriel Arjones Date: Mon, 1 Aug 2022 20:48:55 -0300 Subject: [PATCH] reload description files after loading the init.rb scripts --- .rubocop.yml | 2 +- lib/autoproj/ops/configuration.rb | 6 ++++++ lib/autoproj/os_package_installer.rb | 3 ++- test/ops/test_configuration.rb | 30 ++++++++++++++++++++++++++++ 4 files changed, 39 insertions(+), 2 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 3a1a9071..eee5a0cb 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -20,7 +20,7 @@ Metrics/ParameterLists: Naming/MethodParameterName: AllowedNames: [io, id, to, by, on, in, at, ip, db, ws] -Gemspec/DateAssignment: # new in 1.10 +Gemspec/DeprecatedAttributeAssignment: # new in 1.10 Enabled: true Layout/LineEndStringConcatenationIndentation: # new in 1.18 Enabled: true diff --git a/lib/autoproj/ops/configuration.rb b/lib/autoproj/ops/configuration.rb index da0cccb9..be623679 100644 --- a/lib/autoproj/ops/configuration.rb +++ b/lib/autoproj/ops/configuration.rb @@ -651,6 +651,12 @@ def update_package_sets(only_local: false, ws.manifest.each_package_set do |pkg_set| ws.load_if_present(pkg_set, pkg_set.local_dir, "init.rb") + + # Reload the package set description to account for + # source files that might have been added through + # Autoproj::PackageSet$add_source_file during loading + # of the init.rb scripts + pkg_set.load_description_file end failures diff --git a/lib/autoproj/os_package_installer.rb b/lib/autoproj/os_package_installer.rb index a89edf2d..9f0b9ae6 100644 --- a/lib/autoproj/os_package_installer.rb +++ b/lib/autoproj/os_package_installer.rb @@ -185,7 +185,8 @@ def osdeps_mode_string_to_value(string) when "gem" then modes << "gem" when "pip" then modes << "pip" when "os" then modes << "os" - when "none" then # rubocop:disable Lint/EmptyWhen + when "none" then + # noop else if package_managers.key?(str) modes << str diff --git a/test/ops/test_configuration.rb b/test/ops/test_configuration.rb index 1b760d7f..70ed2d86 100644 --- a/test/ops/test_configuration.rb +++ b/test/ops/test_configuration.rb @@ -377,6 +377,7 @@ def expect_fatal_message(message) it "has only one main package set in the resulting manifest" do package_set_dir = File.join(ws.root_dir, "package_set") root_package_set = ws.manifest.main_package_set + root_package_set.manifest.load File.join(root_package_set.local_dir, "manifest") root_package_set.add_raw_imported_set VCSDefinition.from_raw( { "type" => "local", "url" => package_set_dir } ) @@ -481,7 +482,36 @@ def expect_fatal_message(message) ops.update_configuration(keep_going: false) end end + it "loads source files added in init scripts" do + config_dir = ws.manifest.main_package_set.local_dir + manifest_path = File.join(config_dir, "manifest") + package_set_dir = File.join(config_dir, "foo_set") + FileUtils.mkdir_p package_set_dir + manifest_contents = <<~EOFMANIFEST + package_sets: + - foo_set + EOFMANIFEST + source_contents = "name: foo_set" + test_source_contents = <<~EOFVCS + version_control: + - foo_pkg: + github: foo/foo_pkg + EOFVCS + initrb_contents = "Autoproj::PackageSet.add_source_file "\ + '"source.yml-test"' + + File.write(manifest_path, manifest_contents) + File.write(File.join(package_set_dir, "source.yml"), source_contents) + File.write(File.join(package_set_dir, "source.yml-test"), test_source_contents) + File.write(File.join(package_set_dir, "init.rb"), initrb_contents) + + ops.update_configuration + package_sets = ws.manifest.each_package_set.to_a + raw_vcs = { "foo_pkg" => { "github" => "foo/foo_pkg" } } + assert_equal 2, package_sets.size + assert_equal raw_vcs, package_sets.first.version_control.to_h + end describe "keep_going: true" do before do flexmock(ws.manifest.vcs).should_receive(:needs_import?)