Improve error reporting on run control evaluation
This commit is contained in:
parent
747573c52e
commit
0a83563cad
@ -7,3 +7,12 @@ Feature: run control file evaluation
|
||||
"""
|
||||
When I start uhwm
|
||||
Then the output must contain "run control evaluation"
|
||||
|
||||
Scenario: reports run control code in backtrace on errors
|
||||
Given a run control file with:
|
||||
"""
|
||||
'no error on first line'
|
||||
fail 'fails on second line'
|
||||
"""
|
||||
When I start uhwm
|
||||
Then the output must match /\.uhwmrc\.rb:2:.+fails on second line/
|
||||
|
@ -12,7 +12,7 @@ module Uh
|
||||
def evaluate env
|
||||
rc_path = File.expand_path(env.rc_path)
|
||||
rc = new env
|
||||
rc.evaluate File.read(rc_path) if File.exist?(rc_path)
|
||||
rc.evaluate File.read(rc_path), rc_path if File.exist?(rc_path)
|
||||
end
|
||||
end
|
||||
|
||||
@ -20,8 +20,8 @@ module Uh
|
||||
@env = env
|
||||
end
|
||||
|
||||
def evaluate code
|
||||
instance_eval code
|
||||
def evaluate code, path
|
||||
instance_eval code, path
|
||||
end
|
||||
|
||||
def key keysym, &block
|
||||
|
@ -23,7 +23,8 @@ module Uh
|
||||
end
|
||||
|
||||
it 'tells the new instance to evaluate run control file content' do
|
||||
expect(rc).to receive(:evaluate).with ':run_control_code'
|
||||
expect(rc)
|
||||
.to receive(:evaluate).with(':run_control_code', env.rc_path)
|
||||
allow(described_class).to receive(:new) { rc }
|
||||
described_class.evaluate env
|
||||
end
|
||||
@ -39,12 +40,12 @@ module Uh
|
||||
|
||||
describe '#evaluate' do
|
||||
it 'evaluates given code' do
|
||||
expect { rc.evaluate 'throw :run_control_code' }
|
||||
expect { rc.evaluate 'throw :run_control_code', 'some_path' }
|
||||
.to throw_symbol :run_control_code
|
||||
end
|
||||
|
||||
it 'provides access to assigned env' do
|
||||
expect { rc.evaluate 'fail @env.object_id.to_s' }
|
||||
expect { rc.evaluate 'fail @env.object_id.to_s', 'some_path' }
|
||||
.to raise_error env.object_id.to_s
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user