Skip to content

Commit e8ce511

Browse files
authored
Merge pull request #1277 from godot-rust/bugfix/flaky-test
Fix `node_call_group` test accidentally renaming root tree
2 parents 870c725 + 4b5c53e commit e8ce511

File tree

1 file changed

+10
-28
lines changed

1 file changed

+10
-28
lines changed

itest/rust/src/engine_tests/node_test.rs

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@
88
use std::str::FromStr;
99

1010
use godot::builtin::{vslice, NodePath};
11-
use godot::classes::{Node, Node3D, PackedScene, SceneTree};
12-
use godot::global;
13-
use godot::obj::{NewAlloc, NewGd};
11+
use godot::classes::{Node, Node3D};
12+
use godot::obj::NewAlloc;
1413

1514
use crate::framework::{itest, TestContext};
1615

@@ -60,35 +59,18 @@ fn node_path_from_str(ctx: &TestContext) {
6059
);
6160
}
6261

63-
#[itest(skip)]
64-
fn node_scene_tree() {
65-
let mut child = Node::new_alloc();
66-
child.set_name("kid");
67-
68-
let mut parent = Node::new_alloc();
69-
parent.set_name("parent");
70-
parent.add_child(&child);
71-
72-
let mut scene = PackedScene::new_gd();
73-
let err = scene.pack(&parent);
74-
assert_eq!(err, global::Error::OK);
75-
76-
let mut tree = SceneTree::new_alloc();
77-
let err = tree.change_scene_to_packed(&scene);
78-
assert_eq!(err, global::Error::OK);
79-
80-
// Note: parent + child are not owned by PackedScene, thus need to be freed
81-
// (verified by porting this very test to GDScript)
82-
tree.free();
83-
parent.free();
84-
child.free();
85-
}
86-
62+
// Regression test against call_group() crashing, see https://github.com/godot-rust/gdext/pull/167.
63+
// https://github.com/godot-rust/gdext/commit/207c4e72ac0c24cfb83bab16f856dd09ebc8671c
8764
#[itest]
8865
fn node_call_group(ctx: &TestContext) {
8966
let mut node = ctx.scene_tree.clone();
9067
let mut tree = node.get_tree().unwrap();
9168

9269
node.add_to_group("group");
93-
tree.call_group("group", "set_name", vslice!["name"]);
70+
71+
tree.call_group("group", "set_meta", vslice!["something", true]);
72+
assert!(node.has_meta("something"));
73+
74+
tree.call_group("group", "remove_meta", vslice!["something"]);
75+
assert!(!node.has_meta("something"));
9476
}

0 commit comments

Comments
 (0)