Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add at_least_until to have_no_new_sample #250

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
13 changes: 9 additions & 4 deletions lib/syskit/test/execution_expectations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def self.resolve_orocos_reader(reader, **policy)
#
# Implementation of the {#have_no_new_sample} predicate
class HaveNoNewSample < Roby::Test::ExecutionExpectations::Maintain
def initialize(reader, at_least_during, description, backtrace)
def initialize(reader, at_least, description, backtrace)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same remark about splitting at_least_during / at_least_until in the constructor.

@reader = reader
orocos_reader = ExecutionExpectations.resolve_orocos_reader(reader)
block = proc do
Expand All @@ -39,7 +39,7 @@ def initialize(reader, at_least_during, description, backtrace)
true
end
end
super(at_least_during, block, description, backtrace)
super(at_least, block, description, backtrace)
end

def explain_unachievable(propagation_info)
Expand Down Expand Up @@ -76,10 +76,15 @@ def matching(&block)
# @param [Float] at_least_during no samples should arrive for at
# least that many seconds. This is a minimum.
# @return [nil]
def have_no_new_sample(reader, at_least_during: 0, backtrace: caller(1))
def have_no_new_sample(
reader, at_least_during: nil, at_least_until: nil, backtrace: caller(1)
)
at_least_during = 0 unless at_least_during || at_least_until
description = "#{reader} should not have received a new sample"
add_expectation(
HaveNoNewSample.new(reader, at_least_during, description, backtrace)
HaveNoNewSample.new(
reader, at_least_during || at_least_until, description, backtrace
)
)
end

Expand Down
5 changes: 5 additions & 0 deletions test/test/test_execution_expectations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,11 @@ module Test
.timeout(0.01)
.to { have_no_new_sample task.in_port }
end
it "validates if a sample is not received until an event is emitted" do
plan.add(generator = Roby::EventGenerator.new)
expect_execution { generator.emit }
.to { have_no_new_sample task.in_port, at_least_until: generator }
end
it "fails if the task does emit a new sample" do
e = assert_raises(Roby::Test::ExecutionExpectations::Unmet) do
expect_execution { syskit_write task.in_port, 10 }
Expand Down