Link the ordinary tests once, and keep their debug info to line tables
Eleven `tests/*.rs` were eleven binaries, each linking the whole graph -- `wgpu` and all -- to run a handful of cases. They are modules of one target now, under `tests/cases/`, and `cargo test --test suite layout::` still picks one out. The fuzzers and the `*_cost` measurements stay their own targets: they are run on their own and want to be selectable without building the rest. `profile.test` takes `debug = "line-tables-only"`, which is what a backtrace here actually reads; the type and variable information was the bulk of what the linker was writing. Measured on this machine, rebuilding `iris`'s test targets after a change to the crate: 14.3 s before, 9.8 s with one target, 7.7 s with both. `target/` went from 45 GB to 13 GB. The suite still passes 102 tests, and the binary still carries `.debug_line`. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
39e4ca20e6
commit
cb955f1023
13 files changed
+35
No files matched your search
@@ -0,0 +1,85 @@
|
||||
//! Which widget an input reaches.
|
||||
|
||||
use std::{cell::RefCell, rc::Rc};
|
||||
|
||||
use iris::harness::{Harness, TouchScript};
|
||||
use iris::prelude::*;
|
||||
|
||||
#[test]
|
||||
fn a_press_reaches_only_the_widget_under_the_cursor() {
|
||||
let mut h = Harness::new((400, 200));
|
||||
let clicks = Rc::new(RefCell::new(Vec::new()));
|
||||
|
||||
let (on_left, on_right) = (clicks.clone(), clicks.clone());
|
||||
let left = rect(Color::RED)
|
||||
.width(100)
|
||||
.on(CursorSense::click(), move |_, _| {
|
||||
on_left.borrow_mut().push("left")
|
||||
})
|
||||
.add(&mut h.rsc);
|
||||
let right = rect(Color::BLUE)
|
||||
.on(CursorSense::click(), move |_, _| {
|
||||
on_right.borrow_mut().push("right")
|
||||
})
|
||||
.add(&mut h.rsc);
|
||||
h.set_root((left, right).span(Dir::RIGHT));
|
||||
|
||||
h.click((50, 100));
|
||||
assert_eq!(*clicks.borrow(), ["left"]);
|
||||
|
||||
h.click((300, 100));
|
||||
assert_eq!(*clicks.borrow(), ["left", "right"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hover_ends_when_the_cursor_leaves_the_window() {
|
||||
let mut h = Harness::new((400, 200));
|
||||
let hovered = Rc::new(RefCell::new(0));
|
||||
let ended = Rc::new(RefCell::new(0));
|
||||
|
||||
let (h_count, e_count) = (hovered.clone(), ended.clone());
|
||||
let widget = rect(Color::RED)
|
||||
.on(CursorSense::HoverStart, move |_, _| {
|
||||
*h_count.borrow_mut() += 1
|
||||
})
|
||||
.on(CursorSense::HoverEnd, move |_, _| {
|
||||
*e_count.borrow_mut() += 1
|
||||
})
|
||||
.add(&mut h.rsc);
|
||||
h.set_root(widget);
|
||||
|
||||
h.move_to((200, 100));
|
||||
assert_eq!((*hovered.borrow(), *ended.borrow()), (1, 0));
|
||||
|
||||
// A second sample inside the same widget is not a second hover.
|
||||
h.move_to((210, 100));
|
||||
assert_eq!((*hovered.borrow(), *ended.borrow()), (1, 0));
|
||||
|
||||
h.leave();
|
||||
assert_eq!((*hovered.borrow(), *ended.borrow()), (1, 1));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_recorded_gesture_presses_where_it_says() {
|
||||
let mut h = Harness::new((400, 200));
|
||||
let clicks = Rc::new(RefCell::new(Vec::new()));
|
||||
|
||||
let (on_left, on_right) = (clicks.clone(), clicks.clone());
|
||||
let left = rect(Color::RED)
|
||||
.width(100)
|
||||
.on(CursorSense::click(), move |_, _| {
|
||||
on_left.borrow_mut().push("left")
|
||||
})
|
||||
.add(&mut h.rsc);
|
||||
let right = rect(Color::BLUE)
|
||||
.on(CursorSense::click(), move |_, _| {
|
||||
on_right.borrow_mut().push("right")
|
||||
})
|
||||
.add(&mut h.rsc);
|
||||
h.set_root((left, right).span(Dir::RIGHT));
|
||||
|
||||
let script = TouchScript::parse("0 down 300 100\n80 up 300 100").unwrap();
|
||||
h.replay(&script);
|
||||
|
||||
assert_eq!(*clicks.borrow(), ["right"]);
|
||||
}
|
||||
Reference in new issue
Block a user