Skip to content

Commit 650c2ad

Browse files
committed
Update register-docs tests so they pass again
1 parent 927e5f8 commit 650c2ad

File tree

4 files changed

+22
-13
lines changed

4 files changed

+22
-13
lines changed

itest/rust/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ default = ["codegen-full"]
1414
codegen-full = ["godot/__codegen-full"]
1515
codegen-full-experimental = ["codegen-full", "godot/experimental-godot-api"]
1616
experimental-threads = ["godot/experimental-threads"]
17-
register-docs = ["godot/register-docs"] # TODO remove as soon as constant_test.rs checks bitfields with #[constant] proc-macro
17+
register-docs = ["godot/register-docs"]
1818
serde = ["dep:serde", "dep:serde_json", "godot/serde"]
1919

2020
# Do not add features here that are 1:1 forwarded to the `godot` crate, unless they are needed by itest itself.

itest/rust/src/register_tests/constant_test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ impl godot::obj::cap::ImplementsGodotApi for HasOtherConstants {
164164
}
165165
}
166166

167-
// TODO once this is done via proc-macro, remove `register-docs` feature from itest, and update CI workflows.
167+
// TODO once this is done via proc-macro, see if `register-docs` is still used in register_docs_test.rs. Otherwise, remove feature from Cargo.toml.
168168
godot::sys::plugin_add!(
169169
__GODOT_PLUGIN_REGISTRY in ::godot::private;
170170
::godot::private::ClassPlugin {

itest/rust/src/register_tests/register_docs_test.rs

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -190,16 +190,25 @@ impl FairlyDocumented {
190190
fn documented_signal(p: Vector3, w: f64, node: Gd<Node>);
191191
}
192192

193-
#[itest(focus)]
193+
#[itest]
194194
fn test_register_docs() {
195+
let xml = find_class_docs("FairlyDocumented");
196+
195197
// Uncomment if implementation changes and expected output file should be rewritten.
196-
// std::fs::write(
197-
// "res/registered_docs.xml",
198-
// godot_core::docs::gather_xml_docs().next().unwrap(),
199-
// );
200-
201-
assert_eq!(
202-
include_str!("res/registered_docs.xml"),
203-
godot::docs::gather_xml_docs().next().unwrap()
204-
);
198+
// std::fs::write("../rust/src/register_tests/res/registered_docs.xml", &xml)
199+
// .expect("failed to write docs XML file");
200+
201+
assert_eq!(include_str!("res/registered_docs.xml"), xml);
202+
}
203+
204+
fn find_class_docs(class_name: &str) -> String {
205+
let mut count = 0;
206+
for xml in godot::docs::gather_xml_docs() {
207+
count += 1;
208+
if xml.contains(class_name) {
209+
return xml;
210+
}
211+
}
212+
213+
panic!("Registered docs for class {class_name} not found in {count} XML files");
205214
}

itest/rust/src/register_tests/res/registered_docs.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ these</description>
2525
</description>
2626
</method>
2727

28-
<method name="virtual_documented">
28+
<method name="_virtual_documented">
2929
<return type="()" />
3030
<param index="0" name="node" type="Gd &lt; Node &gt;" />
3131
<description>

0 commit comments

Comments
 (0)