mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2025-12-23 10:11:54 +00:00
Fix tests
This commit is contained in:
parent
da22edbe1a
commit
04ff7b75e5
8 changed files with 23 additions and 25 deletions
|
|
@ -12,7 +12,6 @@ use crate::test_utils::test_prelude::LayerNodeIdentifier;
|
|||
use glam::DVec2;
|
||||
use graph_craft::document::DocumentNode;
|
||||
use graphene_std::InputAccessor;
|
||||
use graphene_std::any::EditorContext;
|
||||
use graphene_std::raster::color::Color;
|
||||
|
||||
/// A set of utility functions to make the writing of editor test more declarative
|
||||
|
|
@ -22,20 +21,20 @@ pub struct EditorTestUtils {
|
|||
}
|
||||
|
||||
impl EditorTestUtils {
|
||||
pub fn create() -> Self {
|
||||
let _ = env_logger::builder().is_test(true).try_init();
|
||||
set_uuid_seed(0);
|
||||
// pub fn create() -> Self {
|
||||
// let _ = env_logger::builder().is_test(true).try_init();
|
||||
// set_uuid_seed(0);
|
||||
|
||||
let (mut editor, runtime) = Editor::new_local_executor();
|
||||
// let (mut editor, runtime) = Editor::new_local_executor();
|
||||
|
||||
// We have to set this directly instead of using `GlobalsMessage::SetPlatform` because race conditions with multiple tests can cause that message handler to set it more than once, which is a failure.
|
||||
// It isn't sufficient to guard the message dispatch here with a check if the once_cell is empty, because that isn't atomic and the time between checking and handling the dispatch can let multiple through.
|
||||
let _ = GLOBAL_PLATFORM.set(Platform::Windows).is_ok();
|
||||
// // We have to set this directly instead of using `GlobalsMessage::SetPlatform` because race conditions with multiple tests can cause that message handler to set it more than once, which is a failure.
|
||||
// // It isn't sufficient to guard the message dispatch here with a check if the once_cell is empty, because that isn't atomic and the time between checking and handling the dispatch can let multiple through.
|
||||
// let _ = GLOBAL_PLATFORM.set(Platform::Windows).is_ok();
|
||||
|
||||
editor.handle_message(PortfolioMessage::Init);
|
||||
// editor.handle_message(PortfolioMessage::Init);
|
||||
|
||||
Self { editor, runtime }
|
||||
}
|
||||
// Self { editor, runtime }
|
||||
// }
|
||||
|
||||
// pub fn eval_graph<'a>(&'a mut self) -> impl std::future::Future<Output = Result<Instrumented, String>> + 'a {
|
||||
// // An inner function is required since async functions in traits are a bit weird
|
||||
|
|
|
|||
|
|
@ -93,9 +93,12 @@ where
|
|||
|
||||
drop(cache_guard);
|
||||
|
||||
let fut = self.node.eval(input);
|
||||
let cache = self.cache.clone();
|
||||
|
||||
Box::pin(async move {
|
||||
let value = self.node.eval(input).await;
|
||||
*self.cache.lock().unwrap() = Some((hash, Arc::new(value.clone())));
|
||||
let value = fut.await;
|
||||
*cache.lock().unwrap() = Some((hash, Arc::new(value.clone())));
|
||||
value
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
use crate::instances::{InstanceRef, Instances};
|
||||
use crate::raster_types::{CPU, RasterDataTable};
|
||||
use crate::vector::VectorDataTable;
|
||||
use crate::{ Context, Ctx, ExtractIndex, ExtractVarArgs, GraphicElement, GraphicGroupTable, WithIndex};
|
||||
use crate::{Context, Ctx, ExtractIndex, ExtractVarArgs, GraphicElement, GraphicGroupTable, WithIndex};
|
||||
use glam::DVec2;
|
||||
|
||||
#[node_macro::node(name("Instance on Points"), category("Instancing"), path(graphene_core::vector))]
|
||||
async fn instance_on_points<T: Into<GraphicElement> + Default + Send + Clone + 'static>(
|
||||
ctx: impl Ctx + WithIndex,
|
||||
ctx: impl Ctx + WithIndex + Sync,
|
||||
points: VectorDataTable,
|
||||
#[implementations(
|
||||
Context -> GraphicGroupTable,
|
||||
|
|
|
|||
|
|
@ -397,7 +397,6 @@ impl Display for TaggedValue {
|
|||
|
||||
pub struct UpcastNode {
|
||||
value: MemoHash<TaggedValue>,
|
||||
inspected: Cell<bool>,
|
||||
}
|
||||
impl<'input> Node<'input, DAny<'input>> for UpcastNode {
|
||||
type Output = FutureAny<'input>;
|
||||
|
|
@ -407,13 +406,12 @@ impl<'input> Node<'input, DAny<'input>> for UpcastNode {
|
|||
}
|
||||
|
||||
fn introspect(&self) -> graphene_core::memo::MonitorIntrospectResult {
|
||||
let inspected = self.inspected.replace(true);
|
||||
graphene_core::memo::MonitorIntrospectResult::Evaluated((Arc::new(self.value.clone().into_inner()) as Arc<dyn std::any::Any + Send + Sync>, !inspected))
|
||||
graphene_core::memo::MonitorIntrospectResult::Evaluated((Arc::new(self.value.clone().into_inner()) as Arc<dyn std::any::Any + Send + Sync>, true))
|
||||
}
|
||||
}
|
||||
impl UpcastNode {
|
||||
pub fn new(value: MemoHash<TaggedValue>) -> Self {
|
||||
Self { value, inspected: Cell::new(false) }
|
||||
Self { value }
|
||||
}
|
||||
}
|
||||
#[derive(Default, Debug, Clone, Copy)]
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ use graph_craft::proto::{ProtoNetwork, ProtoNode};
|
|||
use graph_craft::util::load_network;
|
||||
use graph_craft::wasm_application_io::{EditorPreferences, WasmApplicationIoValue};
|
||||
use graphene_core::text::FontCache;
|
||||
use graphene_std::any::EditorContext;
|
||||
use graphene_std::application_io::{ApplicationIo, ApplicationIoValue, NodeGraphUpdateMessage, NodeGraphUpdateSender, RenderConfig};
|
||||
use graphene_std::wasm_application_io::WasmApplicationIo;
|
||||
use interpreted_executor::dynamic_executor::DynamicExecutor;
|
||||
|
|
@ -180,7 +179,7 @@ fn compile_graph(document_string: String, application_io: Arc<WasmApplicationIo>
|
|||
let mut network = load_network(&document_string);
|
||||
fix_nodes(&mut network);
|
||||
|
||||
let substitutions: std::collections::HashMap<String, DocumentNode> = preprocessor::generate_node_substitutions();
|
||||
let substitutions = preprocessor::generate_node_substitutions();
|
||||
preprocessor::expand_network(&mut network, &substitutions);
|
||||
|
||||
let mut wrapped_network = wrap_network_in_scope(network, Arc::new(FontCache::default()), EditorMetadata::default(), application_io);
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ pub use graph_craft::proto::{Any, NodeContainer, TypeErasedBox, TypeErasedNode};
|
|||
use graph_craft::proto::{DynFuture, FutureAny, SharedNodeContainer};
|
||||
use graphene_core::Context;
|
||||
use graphene_core::ContextDependencies;
|
||||
use graphene_core::EditorContext;
|
||||
use graphene_core::NodeIO;
|
||||
use graphene_core::OwnedContextImpl;
|
||||
use graphene_core::WasmNotSend;
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ fn update_executor<M: Measurement>(name: &str, c: &mut BenchmarkGroup<M>) {
|
|||
c.bench_function(name, |b| {
|
||||
b.iter_batched(
|
||||
|| (executor.clone(), proto_network.clone()),
|
||||
|(mut executor, network)| futures::executor::block_on(executor.update(black_box(network, None))),
|
||||
|(mut executor, network)| futures::executor::block_on(executor.update(black_box(network), None)),
|
||||
criterion::BatchSize::SmallInput,
|
||||
)
|
||||
});
|
||||
|
|
@ -33,7 +33,7 @@ fn run_once<M: Measurement>(name: &str, c: &mut BenchmarkGroup<M>) {
|
|||
let proto_network = network.compile().unwrap().0;
|
||||
|
||||
let executor = futures::executor::block_on(DynamicExecutor::new(proto_network)).unwrap();
|
||||
let context = graphene_std::any::EditorContext::default();
|
||||
let context = graphene_std::EditorContext::default();
|
||||
|
||||
c.bench_function(name, |b| b.iter(|| futures::executor::block_on((&executor).evaluate_from_node(context.clone(), None))));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ fn update_executor(c: &mut Criterion) {
|
|||
let executor = futures::executor::block_on(DynamicExecutor::new(empty)).unwrap();
|
||||
(executor, proto_network)
|
||||
},
|
||||
|(mut executor, network)| futures::executor::block_on(executor.update(criterion::black_box(network, None))),
|
||||
|(mut executor, network)| futures::executor::block_on(executor.update(criterion::black_box(network), None)),
|
||||
criterion::BatchSize::SmallInput,
|
||||
)
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue