lundi 24 février 2020

How to ignore an example when running tests with cargo

I'm making a proc_macro crate where I have 2 examples in the directory examples/.

When I run cargo test, the 2 examples are compiled but one of the examples is failing on purpose and it prevents the test from running. I want to make an example that fails to compile to show the user how it works.

According to the doc this behavior is intended:

They must compile as executables (with a main() function) and load in the library by using extern crate <library-name>. They are compiled when you run your tests to protect them from bitrotting.

This is fine but how can I disable the compilation for my failing example?

Aucun commentaire:

Enregistrer un commentaire