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
|
When I start uhwm
|
||||||
Then the output must contain "run control evaluation"
|
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
|
def evaluate env
|
||||||
rc_path = File.expand_path(env.rc_path)
|
rc_path = File.expand_path(env.rc_path)
|
||||||
rc = new env
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -20,8 +20,8 @@ module Uh
|
|||||||
@env = env
|
@env = env
|
||||||
end
|
end
|
||||||
|
|
||||||
def evaluate code
|
def evaluate code, path
|
||||||
instance_eval code
|
instance_eval code, path
|
||||||
end
|
end
|
||||||
|
|
||||||
def key keysym, &block
|
def key keysym, &block
|
||||||
|
@ -23,7 +23,8 @@ module Uh
|
|||||||
end
|
end
|
||||||
|
|
||||||
it 'tells the new instance to evaluate run control file content' do
|
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 }
|
allow(described_class).to receive(:new) { rc }
|
||||||
described_class.evaluate env
|
described_class.evaluate env
|
||||||
end
|
end
|
||||||
@ -39,12 +40,12 @@ module Uh
|
|||||||
|
|
||||||
describe '#evaluate' do
|
describe '#evaluate' do
|
||||||
it 'evaluates given code' 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
|
.to throw_symbol :run_control_code
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'provides access to assigned env' do
|
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
|
.to raise_error env.object_id.to_s
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user