Skip to content

Commit 8adcf64

Browse files
committed
Fix test harness crashing on failure.
1 parent 559c534 commit 8adcf64

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ This means that druid no longer requires cairo on macOS and uses Core Graphics i
145145
- Added docs generation testing for all features. ([#942] by [@xStrom])
146146
- Renamed `BaseState` to `WidgetState` ([#969] by [@cmyr])
147147
- X11: Reworked error handling ([#982] by [@jneem])
148+
- Fixed test harness crashing on failure. ([#984] by [@xStrom])
148149

149150
### Outside News
150151

@@ -231,6 +232,7 @@ This means that druid no longer requires cairo on macOS and uses Core Graphics i
231232
[#970]: https://github.com/xi-editor/druid/pull/970
232233
[#980]: https://github.com/xi-editor/druid/pull/980
233234
[#982]: https://github.com/xi-editor/druid/pull/982
235+
[#984]: https://github.com/xi-editor/druid/pull/984
234236

235237
## [0.5.0] - 2020-04-01
236238

druid/src/tests/harness.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ impl<T: Data> Harness<'_, T> {
157157
window_size,
158158
};
159159
harness_closure(&mut harness);
160-
harness.piet.finish().expect("piet finish failed");
161160
}
162161
render_context_closure(target)
163162
}
@@ -300,6 +299,16 @@ impl<T: Data> Inner<T> {
300299
}
301300
}
302301

302+
impl<T> Drop for Harness<'_, T> {
303+
fn drop(&mut self) {
304+
// We need to call finish even if a test assert failed
305+
if let Err(err) = self.piet.finish() {
306+
// We can't panic, because we might already be panicking
307+
log::error!("piet finish failed: {}", err);
308+
}
309+
}
310+
}
311+
303312
impl Drop for TargetGuard<'_> {
304313
fn drop(&mut self) {
305314
// we need to call this to clean up the context

0 commit comments

Comments
 (0)