Skip to content

Commit

Permalink
Update register-docs tests so they pass again
Browse files Browse the repository at this point in the history
  • Loading branch information
Bromeon committed Nov 4, 2024
1 parent 6427d45 commit e36c746
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 13 deletions.
2 changes: 1 addition & 1 deletion itest/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ default = ["codegen-full"]
codegen-full = ["godot/__codegen-full"]
codegen-full-experimental = ["codegen-full", "godot/experimental-godot-api"]
experimental-threads = ["godot/experimental-threads"]
register-docs = ["godot/register-docs"] # TODO remove as soon as constant_test.rs checks bitfields with #[constant] proc-macro
register-docs = ["godot/register-docs"]
serde = ["dep:serde", "dep:serde_json", "godot/serde"]

# Do not add features here that are 1:1 forwarded to the `godot` crate, unless they are needed by itest itself.
Expand Down
2 changes: 1 addition & 1 deletion itest/rust/src/register_tests/constant_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ impl godot::obj::cap::ImplementsGodotApi for HasOtherConstants {
}
}

// TODO once this is done via proc-macro, remove `register-docs` feature from itest, and update CI workflows.
// 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.
godot::sys::plugin_add!(
__GODOT_PLUGIN_REGISTRY in ::godot::private;
::godot::private::ClassPlugin {
Expand Down
29 changes: 19 additions & 10 deletions itest/rust/src/register_tests/register_docs_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,16 +190,25 @@ impl FairlyDocumented {
fn documented_signal(p: Vector3, w: f64, node: Gd<Node>);
}

#[itest(focus)]
#[itest]
fn test_register_docs() {
let xml = find_class_docs("FairlyDocumented");

// Uncomment if implementation changes and expected output file should be rewritten.
// std::fs::write(
// "res/registered_docs.xml",
// godot_core::docs::gather_xml_docs().next().unwrap(),
// );

assert_eq!(
include_str!("res/registered_docs.xml"),
godot::docs::gather_xml_docs().next().unwrap()
);
// std::fs::write("../rust/src/register_tests/res/registered_docs.xml", &xml)
// .expect("failed to write docs XML file");

assert_eq!(include_str!("res/registered_docs.xml"), xml);
}

fn find_class_docs(class_name: &str) -> String {
let mut count = 0;
for xml in godot::docs::gather_xml_docs() {
count += 1;
if xml.contains(class_name) {
return xml;
}
}

panic!("Registered docs for class {class_name} not found in {count} XML files");
}
2 changes: 1 addition & 1 deletion itest/rust/src/register_tests/res/registered_docs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ these</description>
</description>
</method>

<method name="virtual_documented">
<method name="_virtual_documented">
<return type="()" />
<param index="0" name="node" type="Gd &lt; Node &gt;" />
<description>
Expand Down

0 comments on commit e36c746

Please sign in to comment.