nushell/crates/nu-plugin-test-support/src
Devyn Cairns 2562e306b6
Improve handling of custom values in plugin examples (#12409)
# Description
Requested by @ayax79. This makes the custom value behavior more correct,
by calling the methods on the plugin to handle the custom values in
examples rather than the methods on the custom values themselves. This
helps for handle-type custom values (like what he's doing with
dataframes).

- Equality checking in `PluginTest::test_examples()` changed to use
`PluginInterface::custom_value_partial_cmp()`
- Base value rendering for `PluginSignature` changed to use
`Plugin::custom_value_to_base_value()`
- Had to be moved closer to `serve_plugin` for this reason, so the test
for writing signatures containing custom values was removed
- That behavior should still be tested to some degree, since if custom
values are not handled, signatures will fail to parse, so all of the
other tests won't work.

# User-Facing Changes

- `Record::sort_cols()` method added to share functionality required by
`PartialCmp`, and it might also be slightly faster
- Otherwise, everything should mostly be the same but better. Plugins
that don't implement special handling for custom values will still work
the same way, because the default implementation is just a pass-through
to the `CustomValue` methods.

# Tests + Formatting
- 🟢 `toolkit fmt`
- 🟢 `toolkit clippy`
- 🟢 `toolkit test`
- 🟢 `toolkit test stdlib`
2024-04-05 21:57:20 -05:00
..
diff.rs Fix #12280: replace difference crate with similar (#12282) 2024-03-25 21:13:12 -05:00
fake_persistent_plugin.rs Add test support crate for plugin developers (#12259) 2024-03-23 13:29:54 -05:00
fake_register.rs Change PluginCommand API to be more like Command (#12279) 2024-03-27 11:59:57 +01:00
lib.rs Change PluginCommand API to be more like Command (#12279) 2024-03-27 11:59:57 +01:00
plugin_test.rs Improve handling of custom values in plugin examples (#12409) 2024-04-05 21:57:20 -05:00
spawn_fake_plugin.rs Add test support crate for plugin developers (#12259) 2024-03-23 13:29:54 -05:00