mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-21 21:25:16 +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
68 lines
1.7 KiB
Rust
68 lines
1.7 KiB
Rust
mod test_util;
|
|
|
|
use std::path::Path;
|
|
|
|
use pretty_assertions::assert_eq;
|
|
|
|
use librojo::{
|
|
imfs::Imfs,
|
|
project::Project,
|
|
rbx_snapshot::{SnapshotContext, snapshot_project_tree},
|
|
};
|
|
|
|
use crate::test_util::{
|
|
snapshot::*,
|
|
};
|
|
|
|
macro_rules! generate_snapshot_tests {
|
|
($($name: ident),*) => {
|
|
$(
|
|
paste::item! {
|
|
#[test]
|
|
fn [<snapshot_ $name>]() {
|
|
let _ = env_logger::try_init();
|
|
|
|
let tests_folder = Path::new(env!("CARGO_MANIFEST_DIR")).join("../test-projects");
|
|
let project_folder = tests_folder.join(stringify!($name));
|
|
run_snapshot_test(&project_folder);
|
|
}
|
|
}
|
|
)*
|
|
};
|
|
}
|
|
|
|
generate_snapshot_tests!(
|
|
empty,
|
|
multi_partition_game,
|
|
nested_partitions,
|
|
single_partition_game,
|
|
single_partition_model,
|
|
transmute_partition
|
|
);
|
|
|
|
fn run_snapshot_test(path: &Path) {
|
|
println!("Running snapshot from project: {}", path.display());
|
|
|
|
let project = Project::load_fuzzy(path)
|
|
.expect("Couldn't load project file for snapshot test");
|
|
|
|
let mut imfs = Imfs::new();
|
|
imfs.add_roots_from_project(&project)
|
|
.expect("Could not add IMFS roots to snapshot project");
|
|
|
|
let context = SnapshotContext {
|
|
plugin_context: None,
|
|
};
|
|
|
|
let mut snapshot = snapshot_project_tree(&context, &imfs, &project)
|
|
.expect("Could not generate snapshot for snapshot test");
|
|
|
|
if let Some(snapshot) = snapshot.as_mut() {
|
|
anonymize_snapshot(path, snapshot);
|
|
}
|
|
|
|
match read_expected_snapshot(path) {
|
|
Some(expected_snapshot) => assert_eq!(snapshot, expected_snapshot),
|
|
None => write_expected_snapshot(path, &snapshot),
|
|
}
|
|
} |