(#14582) Fix noise in LSB facts
Redirect LSB fact's stderr to /dev/null to prevent excess noise.
Hailee Kenney
11 years ago
12 | 12 |
Facter.add(:lsbdistcodename) do
|
13 | 13 |
confine :kernel => [ :linux, :"gnu/kfreebsd" ]
|
14 | 14 |
setcode do
|
15 | |
Facter::Util::Resolution.exec('lsb_release -c -s')
|
|
15 |
Facter::Util::Resolution.exec('lsb_release -c -s 2>/dev/null')
|
16 | 16 |
end
|
17 | 17 |
end
|
12 | 12 |
Facter.add(:lsbdistdescription) do
|
13 | 13 |
confine :kernel => [ :linux, :"gnu/kfreebsd" ]
|
14 | 14 |
setcode do
|
15 | |
if output = Facter::Util::Resolution.exec('lsb_release -d -s')
|
|
15 |
if output = Facter::Util::Resolution.exec('lsb_release -d -s 2>/dev/null')
|
16 | 16 |
# the output may be quoted (at least it is on gentoo)
|
17 | 17 |
output.sub(/^"(.*)"$/,'\1')
|
18 | 18 |
end
|
12 | 12 |
Facter.add(:lsbdistid) do
|
13 | 13 |
confine :kernel => [ :linux, :"gnu/kfreebsd" ]
|
14 | 14 |
setcode do
|
15 | |
Facter::Util::Resolution.exec('lsb_release -i -s')
|
|
15 |
Facter::Util::Resolution.exec('lsb_release -i -s 2>/dev/null')
|
16 | 16 |
end
|
17 | 17 |
end
|
12 | 12 |
Facter.add(:lsbdistrelease) do
|
13 | 13 |
confine :kernel => [ :linux, :"gnu/kfreebsd" ]
|
14 | 14 |
setcode do
|
15 | |
Facter::Util::Resolution.exec('lsb_release -r -s')
|
|
15 |
Facter::Util::Resolution.exec('lsb_release -r -s 2>/dev/null')
|
16 | 16 |
end
|
17 | 17 |
end
|
12 | 12 |
Facter.add(:lsbrelease) do
|
13 | 13 |
confine :kernel => [ :linux, :"gnu/kfreebsd" ]
|
14 | 14 |
setcode do
|
15 | |
Facter::Util::Resolution.exec('lsb_release -v -s')
|
|
15 |
Facter::Util::Resolution.exec('lsb_release -v -s 2>/dev/null')
|
16 | 16 |
end
|
17 | 17 |
end
|
9 | 9 |
Facter.fact(:kernel).stubs(:value).returns kernel
|
10 | 10 |
end
|
11 | 11 |
|
12 | |
it "should return the codename through lsb_release -c -s" do
|
13 | |
Facter::Util::Resolution.stubs(:exec).with('lsb_release -c -s').returns 'n/a'
|
|
12 |
it "should return the codename through lsb_release -c -s 2>/dev/null" do
|
|
13 |
Facter::Util::Resolution.stubs(:exec).with('lsb_release -c -s 2>/dev/null').returns 'n/a'
|
14 | 14 |
Facter.fact(:lsbdistcodename).value.should == 'n/a'
|
15 | 15 |
end
|
16 | 16 |
|
17 | 17 |
it "should return nil if lsb_release is not installed" do
|
18 | |
Facter::Util::Resolution.stubs(:exec).with('lsb_release -c -s').returns nil
|
|
18 |
Facter::Util::Resolution.stubs(:exec).with('lsb_release -c -s 2>/dev/null').returns nil
|
19 | 19 |
Facter.fact(:lsbdistcodename).value.should be_nil
|
20 | 20 |
end
|
21 | 21 |
end
|
9 | 9 |
Facter.fact(:kernel).stubs(:value).returns kernel
|
10 | 10 |
end
|
11 | 11 |
|
12 | |
it "should return the description through lsb_release -d -s" do
|
13 | |
Facter::Util::Resolution.stubs(:exec).with('lsb_release -d -s').returns '"Gentoo Base System release 2.1"'
|
|
12 |
it "should return the description through lsb_release -d -s 2>/dev/null" do
|
|
13 |
Facter::Util::Resolution.stubs(:exec).with('lsb_release -d -s 2>/dev/null').returns '"Gentoo Base System release 2.1"'
|
14 | 14 |
Facter.fact(:lsbdistdescription).value.should == 'Gentoo Base System release 2.1'
|
15 | 15 |
end
|
16 | 16 |
|
17 | 17 |
it "should return nil if lsb_release is not installed" do
|
18 | |
Facter::Util::Resolution.stubs(:exec).with('lsb_release -d -s').returns nil
|
|
18 |
Facter::Util::Resolution.stubs(:exec).with('lsb_release -d -s 2>/dev/null').returns nil
|
19 | 19 |
Facter.fact(:lsbdistdescription).value.should be_nil
|
20 | 20 |
end
|
21 | 21 |
end
|
9 | 9 |
Facter.fact(:kernel).stubs(:value).returns kernel
|
10 | 10 |
end
|
11 | 11 |
|
12 | |
it "should return the id through lsb_release -i -s" do
|
13 | |
Facter::Util::Resolution.stubs(:exec).with('lsb_release -i -s').returns 'Gentoo'
|
|
12 |
it "should return the id through lsb_release -i -s 2>/dev/null" do
|
|
13 |
Facter::Util::Resolution.stubs(:exec).with('lsb_release -i -s 2>/dev/null').returns 'Gentoo'
|
14 | 14 |
Facter.fact(:lsbdistid).value.should == 'Gentoo'
|
15 | 15 |
end
|
16 | 16 |
|
17 | |
it "should return nil if lsb_release is not installed" do
|
18 | |
Facter::Util::Resolution.stubs(:exec).with('lsb_release -i -s').returns nil
|
|
17 |
it "should return nil if lsb_release is not installed 2>/dev/null" do
|
|
18 |
Facter::Util::Resolution.stubs(:exec).with('lsb_release -i -s 2>/dev/null').returns nil
|
19 | 19 |
Facter.fact(:lsbdistid).value.should be_nil
|
20 | 20 |
end
|
21 | 21 |
end
|
9 | 9 |
Facter.fact(:kernel).stubs(:value).returns kernel
|
10 | 10 |
end
|
11 | 11 |
|
12 | |
it "should return the release through lsb_release -r -s" do
|
13 | |
Facter::Util::Resolution.stubs(:exec).with('lsb_release -r -s').returns '2.1'
|
|
12 |
it "should return the release through lsb_release -r -s 2>/dev/null" do
|
|
13 |
Facter::Util::Resolution.stubs(:exec).with('lsb_release -r -s 2>/dev/null').returns '2.1'
|
14 | 14 |
Facter.fact(:lsbdistrelease).value.should == '2.1'
|
15 | 15 |
end
|
16 | 16 |
|
17 | 17 |
it "should return nil if lsb_release is not installed" do
|
18 | |
Facter::Util::Resolution.stubs(:exec).with('lsb_release -r -s').returns nil
|
|
18 |
Facter::Util::Resolution.stubs(:exec).with('lsb_release -r -s 2>/dev/null').returns nil
|
19 | 19 |
Facter.fact(:lsbdistrelease).value.should be_nil
|
20 | 20 |
end
|
21 | 21 |
end
|
9 | 9 |
Facter.fact(:kernel).stubs(:value).returns kernel
|
10 | 10 |
end
|
11 | 11 |
|
12 | |
it "should return the release through lsb_release -v -s" do
|
13 | |
Facter::Util::Resolution.stubs(:exec).with('lsb_release -v -s').returns 'n/a'
|
|
12 |
it "should return the release through lsb_release -v -s 2>/dev/null" do
|
|
13 |
Facter::Util::Resolution.stubs(:exec).with('lsb_release -v -s 2>/dev/null').returns 'n/a'
|
14 | 14 |
Facter.fact(:lsbrelease).value.should == 'n/a'
|
15 | 15 |
end
|
16 | 16 |
|
17 | 17 |
it "should return nil if lsb_release is not installed" do
|
18 | |
Facter::Util::Resolution.stubs(:exec).with('lsb_release -v -s').returns nil
|
|
18 |
Facter::Util::Resolution.stubs(:exec).with('lsb_release -v -s 2>/dev/null').returns nil
|
19 | 19 |
Facter.fact(:lsbrelease).value.should be_nil
|
20 | 20 |
end
|
21 | 21 |
end
|