Skip to content

Commit

Permalink
Merge pull request #1220 from MikaelSmith/FACT-1267
Browse files Browse the repository at this point in the history
(FACT-1267) Fix os.macosx.version.full for .0 releases and update test
  • Loading branch information
joshcooper committed Nov 5, 2015
2 parents 8abd6de + 240bed5 commit 8d2c079
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
17 changes: 12 additions & 5 deletions acceptance/tests/facts/macosx.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,22 @@
# Facts tested: os, processors, networking, identity, kernel
#

confine :to, :platform => /osx-10\.9|osx-10\.10/
confine :to, :platform => /osx-/

agents.each do |agent|
if agent['platform'] =~ /osx-10\.9/
os_version = '10.9'
match = agent['platform'].match(/osx-(10\.\d+)/)
fail_test("Unknown OSX platform #{agent['platform']}") if match.nil?

os_version = match[1]
case os_version
when '10.9'
kernel_major = '13'
else
os_version = '10.10'
when '10.10'
kernel_major = '14'
when '10.11'
kernel_major = '15'
else
fail_test("Unknown os_version #{os_version}")
end

step "Ensure the OS fact resolves as expected"
Expand Down
6 changes: 6 additions & 0 deletions lib/src/facts/osx/operating_system_resolver.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <internal/facts/osx/operating_system_resolver.hpp>
#include <leatherman/execution/execution.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/regex.hpp>
#include <string>

using namespace std;
Expand Down Expand Up @@ -37,6 +38,11 @@ namespace facter { namespace facts { namespace osx {
return result.osx.product.empty() || result.osx.build.empty() || result.osx.version.empty();
});

// If osx.build is missing the patch version, add '.0'
if (boost::regex_match(result.osx.version, boost::regex("^\\d+\\.\\d+$"))) {
result.osx.version += ".0";
}

return result;
}

Expand Down

0 comments on commit 8d2c079

Please sign in to comment.