mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-22 21:55:15 +00:00
* Changes project-related structures to use `BTreeMap` instead of `HashMap` for children to aid determiniusm * Changes imfs-related structures to have total ordering and use `BTreeSet` instead of `HashSet` * Upgrades dependencies to `bx_dom_weak`1.2.0 and rbx_xml 0.5.0 to aid in more determinism stuff * Re-exposes the `RbxSession`'s root project via `root_project()` * Implements `Default` for a couple things * Tweaks visualization code to support visualizing trees not attached to an `RbxSession` * Adds an ID-invariant comparison method for `rbx_tree` relying on previous determinism changes * Adds a (disabled) test to start finding issues in the reconciler with regards to communicativity of snapshot application * Adds a snapshot testing system that operates on `RbxTree` and associated metadata, which are committed in this change
115 lines
2.9 KiB
Rust
115 lines
2.9 KiB
Rust
mod test_util;
|
|
|
|
use std::collections::HashMap;
|
|
|
|
use pretty_assertions::assert_eq;
|
|
use rbx_dom_weak::{RbxTree, RbxInstanceProperties};
|
|
|
|
use librojo::{
|
|
snapshot_reconciler::{RbxSnapshotInstance, reconcile_subtree},
|
|
};
|
|
|
|
use test_util::tree::trees_equal;
|
|
|
|
// TODO: Snapshot application isn't communicative right now with the current
|
|
// snapshot reconciler. In practice this mostly isn't a problem, but presents
|
|
// a problem trying to rely on determinism to make snapshot tests.
|
|
// #[test]
|
|
fn patch_communicativity() {
|
|
let base_tree = RbxTree::new(RbxInstanceProperties {
|
|
name: "DataModel".into(),
|
|
class_name: "DataModel".into(),
|
|
properties: HashMap::new(),
|
|
});
|
|
|
|
let patch_a = RbxSnapshotInstance {
|
|
name: "DataModel".into(),
|
|
class_name: "DataModel".into(),
|
|
children: vec![
|
|
RbxSnapshotInstance {
|
|
name: "Child-A".into(),
|
|
class_name: "Folder".into(),
|
|
..Default::default()
|
|
},
|
|
],
|
|
..Default::default()
|
|
};
|
|
|
|
let patch_b = RbxSnapshotInstance {
|
|
name: "DataModel".into(),
|
|
class_name: "DataModel".into(),
|
|
children: vec![
|
|
RbxSnapshotInstance {
|
|
name: "Child-B".into(),
|
|
class_name: "Folder".into(),
|
|
..Default::default()
|
|
},
|
|
],
|
|
..Default::default()
|
|
};
|
|
|
|
let patch_combined = RbxSnapshotInstance {
|
|
name: "DataModel".into(),
|
|
class_name: "DataModel".into(),
|
|
children: vec![
|
|
RbxSnapshotInstance {
|
|
name: "Child-A".into(),
|
|
class_name: "Folder".into(),
|
|
..Default::default()
|
|
},
|
|
RbxSnapshotInstance {
|
|
name: "Child-B".into(),
|
|
class_name: "Folder".into(),
|
|
..Default::default()
|
|
},
|
|
],
|
|
..Default::default()
|
|
};
|
|
|
|
let root_id = base_tree.get_root_id();
|
|
|
|
let mut tree_a = base_tree.clone();
|
|
|
|
reconcile_subtree(
|
|
&mut tree_a,
|
|
root_id,
|
|
&patch_a,
|
|
&mut Default::default(),
|
|
&mut Default::default(),
|
|
&mut Default::default(),
|
|
);
|
|
|
|
reconcile_subtree(
|
|
&mut tree_a,
|
|
root_id,
|
|
&patch_combined,
|
|
&mut Default::default(),
|
|
&mut Default::default(),
|
|
&mut Default::default(),
|
|
);
|
|
|
|
let mut tree_b = base_tree.clone();
|
|
|
|
reconcile_subtree(
|
|
&mut tree_b,
|
|
root_id,
|
|
&patch_b,
|
|
&mut Default::default(),
|
|
&mut Default::default(),
|
|
&mut Default::default(),
|
|
);
|
|
|
|
reconcile_subtree(
|
|
&mut tree_b,
|
|
root_id,
|
|
&patch_combined,
|
|
&mut Default::default(),
|
|
&mut Default::default(),
|
|
&mut Default::default(),
|
|
);
|
|
|
|
match trees_equal(&tree_a, &tree_b) {
|
|
Ok(_) => {}
|
|
Err(e) => panic!("{}", e),
|
|
}
|
|
} |