diff --git a/.github/workflows/gdext_check.yaml b/.github/workflows/gdext_check.yaml index 94264c1..6b84224 100644 --- a/.github/workflows/gdext_check.yaml +++ b/.github/workflows/gdext_check.yaml @@ -1,4 +1,4 @@ -name: schedule-check +name: Continuous tests on: schedule: - cron: "27 06 * * *" diff --git a/.github/workflows/successful_merge.yaml b/.github/workflows/successful_merge.yaml index 8253aaf..8142134 100644 --- a/.github/workflows/successful_merge.yaml +++ b/.github/workflows/successful_merge.yaml @@ -17,7 +17,7 @@ jobs: doc: name: Deploy documentation on Github Pages - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest steps: - name: Checkout sources diff --git a/README.md b/README.md index 074fe85..f0bb565 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # gd-props -![tests workflow](https://github.com/StatisMike/gd-props/actions/workflows/tests.yaml/badge.svg) +![Schedule tests](https://github.com/StatisMike/gd-props/actions/workflows/gdext_check.yaml/badge.svg) [![Latest compatible gdext](https://byob.yarr.is/StatisMike/gd-props/gdext_latest_success)](https://github.com/godot-rust/gdext) > Resources are akin to the versatile props that set the scene for an interactive masterpiece on the stage of game world. diff --git a/tests/rust/src/bench/gdbin.rs b/tests/rust/src/bench/gdbin.rs index e03d786..8f81983 100644 --- a/tests/rust/src/bench/gdbin.rs +++ b/tests/rust/src/bench/gdbin.rs @@ -1,9 +1,10 @@ -use gd_rehearse::bench::gdbench; +use gd_rehearse::bench::*; use godot::engine::{load, save}; use godot::obj::Gd; use serde::{Deserialize, Serialize}; use crate::remove_file; +use crate::structs::node::{test_resource_setup, TestResourceNode}; use crate::structs::resource::TestResource; #[gdbench(repeat = 10)] @@ -30,13 +31,17 @@ fn deserialize() -> bool { true } -#[gdbench(repeat = 5, scene_path = "res://dev_test.tscn")] -fn gdbin_save() -> bool { +#[gdbench(repeat = 10, setup = test_resource_setup, scene_path = "res://dev_test.tscn")] +fn gdbin_save(ctx: &BenchContext) -> bool { let path = "res://"; let file = "test.gdbin"; let file_path = &format!("{}{}", path, file); - let resource = TestResource::new_random(50, 50); + let resource = ctx + .get_setup_node_as::("TestResourceNode") + .bind() + .res + .clone(); save(resource, file_path); diff --git a/tests/rust/src/bench/gdron.rs b/tests/rust/src/bench/gdron.rs index b7433cc..48e0d27 100644 --- a/tests/rust/src/bench/gdron.rs +++ b/tests/rust/src/bench/gdron.rs @@ -1,9 +1,10 @@ -use gd_rehearse::bench::gdbench; +use gd_rehearse::bench::{gdbench, BenchContext}; use godot::engine::{load, save}; use godot::obj::Gd; use serde::{Deserialize, Serialize}; use crate::remove_file; +use crate::structs::node::{test_resource_setup, TestResourceNode}; use crate::structs::resource::TestResource; #[gdbench(repeat = 10)] @@ -30,13 +31,17 @@ fn deserialize() -> bool { true } -#[gdbench(repeat = 5, scene_path = "res://dev_test.tscn")] -fn gdron_save() -> bool { +#[gdbench(repeat = 10, setup = test_resource_setup, scene_path = "res://dev_test.tscn")] +fn gdron_save(ctx: &BenchContext) -> bool { let path = "res://"; let file = "test.gdron"; let file_path = &format!("{}{}", path, file); - let resource = TestResource::new_random(50, 50); + let resource = ctx + .get_setup_node_as::("TestResourceNode") + .bind() + .res + .clone(); save(resource, file_path); diff --git a/tests/rust/src/itest/export.rs b/tests/rust/src/itest/export.rs index 5b2c06b..65acf42 100644 --- a/tests/rust/src/itest/export.rs +++ b/tests/rust/src/itest/export.rs @@ -1,4 +1,4 @@ -use gd_rehearse::{itest::gditest, CaseContext}; +use gd_rehearse::itest::*; use godot::{ builtin::{GString, NodePath}, engine::NodeExt, @@ -7,7 +7,7 @@ use godot::{ use crate::structs::node::ExportTestNode; #[gditest(scene_path = "res://export_test.tscn")] -fn exported_can_retrieve_node(ctx: &CaseContext) { +fn exported_can_retrieve_node(ctx: &TestContext) { let node = ctx .scene_tree() .try_get_node_as::(NodePath::from("ExportTestNode")); @@ -15,7 +15,7 @@ fn exported_can_retrieve_node(ctx: &CaseContext) { } #[gditest(scene_path = "res://export_test.tscn")] -fn exported_bundled_works(ctx: &CaseContext) { +fn exported_bundled_works(ctx: &TestContext) { let node = ctx .scene_tree() .try_get_node_as::(NodePath::from("ExportTestNode")) @@ -61,7 +61,7 @@ fn exported_bundled_works(ctx: &CaseContext) { } #[gditest(scene_path = "res://export_test.tscn")] -fn exported_ext_works(ctx: &CaseContext) { +fn exported_ext_works(ctx: &TestContext) { let node = ctx .scene_tree() .try_get_node_as::(NodePath::from("ExportTestNode")) diff --git a/tests/rust/src/structs/node.rs b/tests/rust/src/structs/node.rs index 49d9837..5a41e69 100644 --- a/tests/rust/src/structs/node.rs +++ b/tests/rust/src/structs/node.rs @@ -1,8 +1,9 @@ -use godot::engine::INode; -use godot::obj::Gd; +use gd_rehearse::bench::BenchContext; +use godot::engine::{INode, Node}; +use godot::obj::{Base, Gd, NewAlloc}; use godot::register::{godot_api, GodotClass}; -use super::resource::{WithBundledGd, WithExtGd}; +use super::resource::{TestResource, WithBundledGd, WithExtGd}; #[derive(GodotClass)] #[class(base=Node)] @@ -15,7 +16,7 @@ pub struct ExportTestNode { #[godot_api] impl INode for ExportTestNode { - fn init(_base: godot::obj::Base) -> Self { + fn init(_base: Base) -> Self { // "res://export_test/test_resource.gdron" let bundle_res = Gd::::default(); // "res://export_test/with_ext_gd.gdron" @@ -40,3 +41,22 @@ impl ExportTestNode { self.ext_res.clone() } } + +#[derive(GodotClass)] +#[class(base=Node)] +pub(crate) struct TestResourceNode { + pub(crate) res: Gd, +} + +#[godot_api] +impl INode for TestResourceNode { + fn init(_base: Base) -> Self { + Self { + res: TestResource::new_random(100, 100), + } + } +} + +pub(crate) fn test_resource_setup(ctx: &mut BenchContext) { + ctx.setup_add_node(TestResourceNode::new_alloc().upcast(), "TestResourceNode"); +}