Test blocking worker (UAT)
This commit is contained in:
parent
eaa1d279dc
commit
6cfed91653
@ -27,6 +27,17 @@ Then /^the output must not match \/([^\/]+)\/([a-z]*)$/ do |pattern, options|
|
|||||||
expect(all_output).not_to match Regexp.new(pattern, options)
|
expect(all_output).not_to match Regexp.new(pattern, options)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Then /^the output must match \/([^\/]+)\/([a-z]*) at least (\d+) times$/ do
|
||||||
|
|pattern, options, times|
|
||||||
|
uhwm_wait_output Regexp.new(pattern, options), times.to_i
|
||||||
|
end
|
||||||
|
|
||||||
|
Then /^the output must match \/([^\/]+)\/([a-z]*) exactly (\d+) times$/ do
|
||||||
|
|pattern, options, times|
|
||||||
|
scans = uhwm_wait_output Regexp.new(pattern, options)
|
||||||
|
expect(scans.size).to eq times.to_i
|
||||||
|
end
|
||||||
|
|
||||||
Then /^the output must contain:$/ do |content|
|
Then /^the output must contain:$/ do |content|
|
||||||
uhwm_wait_output content.to_s
|
uhwm_wait_output content.to_s
|
||||||
end
|
end
|
||||||
|
@ -9,6 +9,10 @@ When /^I press the ([^ ]+) keys?$/ do |keys|
|
|||||||
x_key keys
|
x_key keys
|
||||||
end
|
end
|
||||||
|
|
||||||
|
When /^I press the ([^ ]+) keys? (\d+) times$/ do |keys, times|
|
||||||
|
times.to_i.times { x_key keys }
|
||||||
|
end
|
||||||
|
|
||||||
When /^a window requests to be mapped$/ do
|
When /^a window requests to be mapped$/ do
|
||||||
x_client.map.sync
|
x_client.map.sync
|
||||||
end
|
end
|
||||||
|
15
features/workers/block.feature
Normal file
15
features/workers/block.feature
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
Feature: blocking worker
|
||||||
|
|
||||||
|
Scenario: processes initial events
|
||||||
|
Given uhwm is running with options -d -w block
|
||||||
|
Then the output must match /xevent/i at least 2 times
|
||||||
|
|
||||||
|
Scenario: processes generated events
|
||||||
|
Given a run control file with:
|
||||||
|
"""
|
||||||
|
key(:f) { puts 'testing_worker_read' }
|
||||||
|
"""
|
||||||
|
And uhwm is running with options -d -w block
|
||||||
|
When I press the alt+f key 3 times
|
||||||
|
And I quit uhwm
|
||||||
|
Then the output must match /(testing_worker_read)/ exactly 3 times
|
@ -29,19 +29,21 @@ module Uh
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def uhwm_wait_output message
|
def uhwm_wait_output message, times = 1, value = nil
|
||||||
output = -> { @process.stdout + @process.stderr }
|
output = -> { @process.stdout + @process.stderr }
|
||||||
timeout_until do
|
timeout_until do
|
||||||
case message
|
case message
|
||||||
when Regexp then output.call =~ message
|
#when Regexp then output.call.scan(message).size >= times
|
||||||
when String then output.call.include? message
|
when Regexp then (value = output.call.scan(message)).size >= times
|
||||||
|
when String then output.call.include? message
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
value
|
||||||
rescue TimeoutError => e
|
rescue TimeoutError => e
|
||||||
fail [
|
fail <<-eoh
|
||||||
"expected `#{message}' not seen after #{e.timeout} seconds in:",
|
expected `#{message}' (#{times}) not seen after #{e.timeout} seconds in:
|
||||||
" ```\n#{output.call.lines.map { |e| " #{e}" }.join} ```"
|
```\n#{output.call.lines.map { |e| " #{e}" }.join} ```
|
||||||
].join "\n"
|
eoh
|
||||||
end
|
end
|
||||||
|
|
||||||
def uhwm_wait_ready
|
def uhwm_wait_ready
|
||||||
|
Loading…
x
Reference in New Issue
Block a user