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

Fix failure when shrinking tests with duplicates in hypothesis-ruby tests #1354

Merged
merged 2 commits into from
Jun 25, 2018
Merged
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
4 changes: 4 additions & 0 deletions conjecture-rust/RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
RELEASE_TYPE: patch

This release fixes an occasional assertion failure that could occur
when shrinking a failing test.
9 changes: 7 additions & 2 deletions conjecture-rust/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -408,15 +408,20 @@ where
fn minimize_duplicated_blocks(&mut self) -> StepResult {
let mut i = 0;
let mut targets = self.calc_duplicates();

while i < targets.len() {
let target = mem::replace(&mut targets[i], Vec::new());
let max_target = *target.iter().max().unwrap();

i += 1;
assert!(target.len() > 0);
let v = self.shrink_target.record[target[0]];
let base = self.shrink_target.record.clone();

let w = minimize_integer(v, |t| {
let mut attempt = base.clone();
if max_target >= self.shrink_target.record.len() {
return Ok(false);
}
let mut attempt = self.shrink_target.record.clone();
for i in &target {
attempt[*i] = t
}
Expand Down
4 changes: 4 additions & 0 deletions hypothesis-ruby/RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
RELEASE_TYPE: patch

This release fixes an occasional `RuntimeError` that could occur
when shrinking a failing test.