diff --git a/itest/rust/Cargo.toml b/itest/rust/Cargo.toml index ce3a754c3..28516f1f8 100644 --- a/itest/rust/Cargo.toml +++ b/itest/rust/Cargo.toml @@ -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. diff --git a/itest/rust/src/register_tests/constant_test.rs b/itest/rust/src/register_tests/constant_test.rs index 5102b1475..a4e6163a3 100644 --- a/itest/rust/src/register_tests/constant_test.rs +++ b/itest/rust/src/register_tests/constant_test.rs @@ -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 { diff --git a/itest/rust/src/register_tests/register_docs_test.rs b/itest/rust/src/register_tests/register_docs_test.rs index 177c0af7b..848e9ab95 100644 --- a/itest/rust/src/register_tests/register_docs_test.rs +++ b/itest/rust/src/register_tests/register_docs_test.rs @@ -190,16 +190,25 @@ impl FairlyDocumented { fn documented_signal(p: Vector3, w: f64, node: Gd); } -#[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"); } diff --git a/itest/rust/src/register_tests/res/registered_docs.xml b/itest/rust/src/register_tests/res/registered_docs.xml index ea575dd34..55eefd5f8 100644 --- a/itest/rust/src/register_tests/res/registered_docs.xml +++ b/itest/rust/src/register_tests/res/registered_docs.xml @@ -25,7 +25,7 @@ these - +