-
Notifications
You must be signed in to change notification settings - Fork 4
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
Figure out a testing story. #4
Comments
See https://github.com/tabatkins/bikeshed/tree/master/tests. The idea is, given an input .bs, does it generate the expected .html. |
I use the serialize method of |
Alternatively, can we parse the bikeshed HTML with kuchiki, and serialize it back to guarantee it's idempotent? Output doesn't have to be whitespace-compatible IMO. |
That makes sense if there's nothing special about the serializer in |
That's also fine, but you'll still run into the whitespace issues I suspect. And potentially attribute ordering issues as well. (Attribute order is unfortunately still implementation-defined.) |
Yeah, however those issues should be easy to work around / ignore in the comparison (sorting the attributes, and skipping child whitespace text nodes where appropriate). So it seems pretty reasonable to me. |
I'm trying to compare DOM trees in this way: fn is_equal(lhs: &NodeRef, rhs: &NodeRef) -> bool {
if lhs.data() != rhs.data() {
return false;
}
let lhs_children = lhs.children().collect::<Vec<NodeRef>>();
let rhs_children = rhs.children().collect::<Vec<NodeRef>>();
if lhs_children.len() != rhs_children.len() {
return false;
}
for (lc, rc) in lhs_children.iter().zip(rhs_children.iter()) {
if !is_equal(lc, rc) {
return false;
}
}
true
} But it isn't working because whitespace characters that are outside of HTML elements will be treated as text nodes (
|
DOM-based comparison seems a little more flexible so you can document in code what kind of whitespace or attribute differences are acceptable. If you do string-based you might run into issues such as the hashmap ordering of attributes being different. |
The DOM-based comparison is working now. See #12. |
We should figure out how do we want bikeshed-rs to be tested.
This probably involves:
Looking into how upstream bikeshed is tested. If we can come up with a way to share the tests that'd be best.
Decide whether we want to use regular
#[test]
functions, or something more like whatcbindgen
andbindgen
use, wherebuild.rs
basically reads atests/
folder and auto-generates the relevant cargo tests: https://github.com/eqrion/cbindgen/blob/master/build.rsThe text was updated successfully, but these errors were encountered: