Skip to content

Commit

Permalink
Merge pull request #611 from yast/fix_for_new_parser
Browse files Browse the repository at this point in the history
Fix for new parser
  • Loading branch information
jreidinger committed May 18, 2020
2 parents f61e007 + 98dd959 commit 9d25cb7
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 37 deletions.
8 changes: 8 additions & 0 deletions package/autoyast2.changes
@@ -1,3 +1,11 @@
-------------------------------------------------------------------
Mon May 18 07:12:41 UTC 2020 - Josef Reidinger <jreidinger@suse.com>

- Fix error reporting for invalid profile to respect new API
(bsc#1171412)
- fix profile loading test
- 4.3.2

-------------------------------------------------------------------
Mon May 11 14:27:50 UTC 2020 - Josef Reidinger <jreidinger@suse.com>

Expand Down
2 changes: 1 addition & 1 deletion package/autoyast2.spec
Expand Up @@ -22,7 +22,7 @@
%endif

Name: autoyast2
Version: 4.3.1
Version: 4.3.2
Release: 0
Summary: YaST2 - Automated Installation
License: GPL-2.0-only
Expand Down
24 changes: 12 additions & 12 deletions src/modules/Profile.rb
Expand Up @@ -9,6 +9,8 @@

module Yast
class ProfileClass < Module
include Yast::Logger

# All these sections are handled by AutoYaST (or Installer) itself,
# it doesn't use any external AutoYaST client for them
GENERIC_PROFILE_SECTIONS = [
Expand Down Expand Up @@ -712,20 +714,18 @@ def ReadXML(file)
@current = XML.XMLToYCPFile(file)
end

xml_error = XML.XMLError
if xml_error && !xml_error.empty?
# autoyast has read the autoyast configuration file but something went wrong
message = _(
"The XML parser reported an error while parsing the autoyast profile. " \
"The error message is:\n"
)
message += xml_error
Yast2::Popup.show(message, headline: :error)
return false
end

Import(@current)
true
rescue Yast::XMLDeserializationError => e
# autoyast has read the autoyast configuration file but something went wrong
message = _(
"The XML parser reported an error while parsing the autoyast profile. " \
"The error message is:\n"
)
message += e.message
log.info "xml parsing error #{e.inspect}"
Yast2::Popup.show(message, headline: :error)
false
end

def setMValue(l, v, m)
Expand Down
29 changes: 5 additions & 24 deletions test/Y2ModuleConfig_test.rb
Expand Up @@ -10,30 +10,11 @@
describe Yast::Y2ModuleConfig do

DESKTOP_DATA = YAML.load_file(FIXTURES_PATH.join("desktop_files", "desktops.yml"))
AVAILABLE_CLIENTS = ["deploy_image_auto", "files_auto", "general_auto", "scripts_auto",
"software_auto", "services-manager_auto"].freeze

before do
allow(Yast::WFM).to receive(:ClientExists).with("audit-laf_auto").and_return(false)
allow(Yast::WFM).to receive(:ClientExists).with("autofs_auto").and_return(false)
allow(Yast::WFM).to receive(:ClientExists).with("ca_mgm_auto").and_return(false)
allow(Yast::WFM).to receive(:ClientExists).with("deploy_image_auto").and_return(true)
allow(Yast::WFM).to receive(:ClientExists).with("files_auto").and_return(true)
allow(Yast::WFM).to receive(:ClientExists).with("firstboot_auto").and_return(false)
allow(Yast::WFM).to receive(:ClientExists).with("general_auto").and_return(true)
allow(Yast::WFM).to receive(:ClientExists).with("inetd_auto").and_return(false)
allow(Yast::WFM).to receive(:ClientExists).with("language_auto").and_return(false)
allow(Yast::WFM).to receive(:ClientExists).with("pxe_auto").and_return(false)
allow(Yast::WFM).to receive(:ClientExists).with("restore_auto").and_return(false)
allow(Yast::WFM).to receive(:ClientExists).with("runlevel_auto").and_return(false)
allow(Yast::WFM).to receive(:ClientExists).with("scripts_auto").and_return(true)
allow(Yast::WFM).to receive(:ClientExists).with("software_auto").and_return(true)
allow(Yast::WFM).to receive(:ClientExists).with("sshd_auto").and_return(false)
allow(Yast::WFM).to receive(:ClientExists).with("sysconfig_auto").and_return(false)
allow(Yast::WFM).to receive(:ClientExists).with("unknown_profile_item_1_auto").and_return(false)
allow(Yast::WFM).to receive(:ClientExists).with("unknown_profile_item_2_auto").and_return(false)
allow(Yast::WFM).to receive(:ClientExists).with("partitioning_auto").and_return(false)
allow(Yast::WFM).to receive(:ClientExists).with("upgrade_auto").and_return(false)
allow(Yast::WFM).to receive(:ClientExists).with("cobbler_auto").and_return(false)
allow(Yast::WFM).to receive(:ClientExists).with("services-manager_auto").and_return(true)
allow(Yast::WFM).to receive(:ClientExists) { |c| AVAILABLE_CLIENTS.include?(c) }
end

describe "#unhandled_profile_sections" do
Expand All @@ -44,8 +25,8 @@
Yast::Profile.ReadXML(profile_unhandled)

expect(Yast::Y2ModuleConfig.unhandled_profile_sections).to contain_exactly(
"audit-laf", "autofs", "ca_mgm", "cobbler", "firstboot", "inetd", "language", "restore",
"sshd", "sysconfig", "unknown_profile_item_1", "unknown_profile_item_2"
"audit-laf", "autofs", "bootloader", "ca_mgm", "cobbler", "firstboot", "inetd", "language",
"report", "restore", "sshd", "sysconfig", "unknown_profile_item_1", "unknown_profile_item_2"
)
end
end
Expand Down

0 comments on commit 9d25cb7

Please sign in to comment.