Skip to content
This repository has been archived by the owner on Feb 1, 2018. It is now read-only.

Added verbose logger. #55

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions lib/bwoken.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'fileutils'
require 'logger'

module Bwoken
class << self
Expand Down Expand Up @@ -78,5 +79,18 @@ def results_path
end
end

def verbose=(value)
@verbose = value
end

def verbose
!! @verbose
end

def logger
@logger ||= Logger.new(STDOUT).tap do |logger|
logger.level = verbose ? Logger::DEBUG : Logger::INFO
end
end
end
end
2 changes: 2 additions & 0 deletions lib/bwoken/build.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ def cmd
def compile
formatter.before_build_start

Bwoken.logger.debug cmd

succeeded, out_string, err_string = RUBY_VERSION == '1.8.7' ? compile_18 : compile_19_plus

if succeeded
Expand Down
1 change: 1 addition & 0 deletions lib/bwoken/cli/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def initialize opts

Bwoken.integration_path = options[:'integration-path']
Bwoken.app_name = options[:'product-name']
Bwoken.verbose = options[:'verbose']
end

def run
Expand Down
2 changes: 2 additions & 0 deletions lib/bwoken/script.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ def device_flag
def run
formatter.before_script_run path

Bwoken.logger.debug cmd

Open3.popen3(cmd) do |stdin, stdout, stderr, wait_thr|
exit_status = formatter.format stdout
raise ScriptFailedError.new('Test Script Failed') unless exit_status == 0
Expand Down
7 changes: 7 additions & 0 deletions spec/lib/bwoken/script_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ class Simulator; end
subject.run
end

it 'logs the command being run' do
subject.stub(:cmd).and_return('cmd')
Open3.stub(:popen3)
Bwoken.logger.should_receive(:debug).with('cmd')
subject.run
end

context 'when passing' do
it 'does not raise a ScriptFailedError' do
Open3.stub(:popen3).and_yield(*%w(in out err thr))
Expand Down