Skip to content

Commit

Permalink
merged with SLES15
Browse files Browse the repository at this point in the history
  • Loading branch information
schubi2 committed Aug 23, 2018
2 parents 049467a + 104b9a8 commit f45ea70
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 5 deletions.
7 changes: 7 additions & 0 deletions package/autoyast2.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Thu Aug 23 14:25:55 CEST 2018 - schubi@suse.de

- AutoInstallRules: Fixed crash while merging profiles.
(bsc#1105711)
- 4.0.61

-------------------------------------------------------------------
Tue Aug 21 08:01:33 UTC 2018 - knut.anderssen@suse.com

Expand Down
2 changes: 1 addition & 1 deletion package/autoyast2.spec
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
%endif

Name: autoyast2
Version: 4.0.60
Version: 4.0.61
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand Down
8 changes: 4 additions & 4 deletions src/modules/AutoInstallRules.rb
Original file line number Diff line number Diff line change
Expand Up @@ -910,13 +910,13 @@ def merge_profiles(base_profile, with, to)
# @param [String] result_profile the resulting control file path
# @return [Boolean] true on success
def Merge(result_profile)
base_profile = File.join(AutoinstConfig.tmpdir, "base_profile.xml")
merge_profile = File.join(AutoinstConfig.tmpdir, "result.xml")
base_profile = File.join(AutoinstConfig.tmpDir, "base_profile.xml")
merge_profile = File.join(AutoinstConfig.tmpDir, "result.xml")
ok = true
skip = false
error = false
@tomerge.each do |file|
log.info("Working on file: %1", file)
log.info("Working on file: #{file}")
current_profile = File.join(AutoinstConfig.local_rules_location, file)
if !skip
if !XML_cleanup(current_profile, base_profile)
Expand All @@ -932,7 +932,7 @@ def Merge(result_profile)
elsif !error
xsltret = merge_profiles(base_profile, current_profile, merge_profile)

log.info("Merge result: %1", xsltret)
log.info("Merge result: #{xsltret}")
if xsltret["exit"] != 0 || xsltret.fetch("stderr", "") != ""
log.error("Merge Failed")
StdErrLog(xsltret.fetch("stderr", ""))
Expand Down
48 changes: 48 additions & 0 deletions test/AutoInstallRules_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -279,4 +279,52 @@
end
end
end

describe '#Merge' do
let(:tmp_dir) { File.join(root_path, 'tmp') }
let(:result_path) { File.join(tmp_dir, 'result.xml') }
let(:second_path) { File.join(tmp_dir, 'second.xml') }
let(:base_profile_path) { File.join(tmp_dir, 'base_profile.xml') }

around(:each) do |example|
FileUtils.rm_rf(tmp_dir) if Dir.exist?(tmp_dir)
FileUtils.mkdir(tmp_dir)
example.run
FileUtils.rm_rf(tmp_dir)
end

before(:each) do
allow(Yast::AutoinstConfig).to receive(:tmpDir).and_return(tmp_dir)
allow(Yast::AutoinstConfig).to receive(:local_rules_location).and_return(tmp_dir)
subject.reset
end

context 'when no XML profile has been given to merge' do
it 'does not read and merge any XML profile' do
expect(subject).to_not receive(:merge_profiles)
expect(subject).not_to receive(:XML_cleanup)
expect(subject.Merge(result_path)).to eq(true)
end
end

context 'when only one XML profile is given' do
it 'does read but not merge this XML profile' do
subject.CreateFile("first.xml")
expect(subject).to_not receive(:merge_profiles)
expect(subject).to receive(:XML_cleanup).at_least(:once).and_return(true)
expect(subject.Merge(result_path)).to eq(true)
end
end

context 'when two XML profiles are given' do
it 'merges two XML profiles' do
subject.CreateFile("first.xml")
subject.CreateFile("second.xml")
expect(subject).to receive(:XML_cleanup).at_least(:once).and_return(true)
expect(subject).to receive(:merge_profiles).with(base_profile_path,
second_path, result_path).and_return({ 'exit' => 0, 'stderr' => '', 'stdout' => '' })
expect(subject.Merge(result_path)).to eq(true)
end
end
end
end

0 comments on commit f45ea70

Please sign in to comment.