SoniEx2
SoniEx2

Reputation: 2044

How can I provide a custom test attribute?

I have a library for writing hexchat plugins. I'd like to be able to write unit tests for those. How do I add something like #[test], but for testing plugins from within hexchat?

Upvotes: 1

Views: 243

Answers (1)

Shepmaster
Shepmaster

Reputation: 431589

How do I add something like #[test]

You don't, at least not yet.

In nightly Rust, you could write a compiler plugin that would allow you to add such an attribute, but the attribute isn't the important part.

The collection of all the annotated functions and generation of the testing harness are all hardcoded into the rustc executable. There are no user-facing hooks to do the same operations.

Experimental RFC 2318 aims to rectify this by making it possible to create custom test frameworks with the same ergonomics as the built in framework.

Existing custom test frameworks use macros / procedural macros / syntax extensions to expand their code to fit into the built in test framework.

Upvotes: 2

Related Questions