ratatui-org / ratatui

Rust library that's all about cooking up terminal user interfaces (TUIs) 👨‍🍳🐀
https://ratatui.rs
MIT License
8.86k stars 269 forks source link

Running `cargo test` fails #1109

Closed kdheepak closed 1 month ago

kdheepak commented 1 month ago

Problem

Running cargo test fails:

error[E0405]: cannot find trait `WidgetRef` in this scope
   --> src/widgets.rs:271:6
    |
24  | impl WidgetRef for Farewell {
    |      ^^^^^^^^^ help: a trait with a similar name exists: `Widget`
    |
...
error[E0405]: cannot find trait `WidgetRef` in this scope
   --> src/widgets.rs:293:26
    |
46  | let widgets: Vec<Box<dyn WidgetRef>> = vec![Box::new(greeting), Box::new(farewell)];
    |                          ^^^^^^^^^ help: a trait with a similar name exists: `Widget`
    |
...
etc

These are the tests that fail:

Couldn't compile the test.

failures:
    src/terminal/frame.rs - terminal::frame::Frame<'_>::render_stateful_widget_ref (line 140)
    src/terminal/frame.rs - terminal::frame::Frame<'_>::render_widget_ref (line 85)
    src/widgets.rs - widgets::Option<W> (line 323)
    src/widgets.rs - widgets::StatefulWidgetRef (line 370)
    src/widgets.rs - widgets::WidgetRef (line 250)

test result: FAILED. 309 passed; 5 failed; 8 ignored; 0 measured; 0 filtered out; finished in 31.93s

I'm assuming that these need to be feature gated differently?

TadoTheMiner commented 1 month ago

Paradoxically cargo make test works

kdheepak commented 1 month ago

I believe that is because --features=all-widgets is included in that command.

TadoTheMiner commented 1 month ago

So they should have #[cfg(feature = "all-widgets")] on them.

kdheepak commented 1 month ago

My bad, it's not all-widgets, it's either unstable-widget-ref or unstable.

TadoTheMiner commented 1 month ago

Well the problem is that we can't add #[cfg(feature = "unstrable-widget-ref")] to the impl because it would break code not using the feature. It could be in fututre realease as a breaking change

joshka commented 1 month ago

Well the problem is that we can't add #[cfg(feature = "unstrable-widget-ref")] to the impl because it would break code not using the feature. It could be in fututre realease as a breaking change

You can however add this to the top of the doc tests which break. See #1117