mirror of
https://github.com/zhigang1992/boxen.git
synced 2026-01-12 17:12:46 +08:00
Add logic to Puppet status code
This is used in multiple places now, and it should be boxed up with the Puppet status anyway.
This commit is contained in:
@@ -6,6 +6,14 @@ module Boxen
|
||||
# Manages an invocation of puppet.
|
||||
|
||||
class Puppeteer
|
||||
|
||||
Status = Struct.new(:code) do
|
||||
# Puppet's detailed exit codes reserves 2 for a successful run with changes
|
||||
def success?
|
||||
[0,2].include?(code)
|
||||
end
|
||||
end
|
||||
|
||||
attr_reader :config
|
||||
|
||||
def initialize(config)
|
||||
@@ -77,7 +85,7 @@ module Boxen
|
||||
warn command.join " " if config.debug?
|
||||
Boxen::Util.sudo *command
|
||||
|
||||
$?.exitstatus
|
||||
Status.new($?.exitstatus)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -75,4 +75,15 @@ class BoxenPuppeteerTest < Boxen::Test
|
||||
|
||||
assert found, "Flags must include #{flag} #{value}."
|
||||
end
|
||||
|
||||
def test_status
|
||||
status = Boxen::Puppeteer::Status.new(0)
|
||||
assert status.success?
|
||||
|
||||
status = Boxen::Puppeteer::Status.new(2)
|
||||
assert status.success?
|
||||
|
||||
status = Boxen::Puppeteer::Status.new(1)
|
||||
refute status.success?
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user