Test harness for procedural macros
Working on MVP :)
You can use a relative path to the local dependency.
No need to put [lib]
section.
[package]
name = "awesome-project-tests"
edition = "2018"
publish = false
[dependencies]
futures = "1"
my-lunatic-dep = { path = "../../my-lunatic-dep" }
test_nodes.rs
use flaterm_macro::layout;
pub fn test() {
layout! {
<Block>
<Text />
</Block>
};
}
test_nodes.stdout
#![feature(prelude_import)]
#[prelude_import]
use std::prelude::rust_2018::*;
#[macro_use]
extern crate std;
use flaterm_macro::layout;
pub fn test() {
{
let mut __flaterm_l = ::flaterm::Node::new(::std::string::String::from("Block"));
let mut __flaterm_c: ::std::vec::Vec<::flaterm::Node> = ::std::default::Default::default();
__flaterm_c.push(::std::convert::Into::into({
let mut __flaterm_l = ::flaterm::Node::new(::std::string::String::from("Text"));
__flaterm_l
}));
__flaterm_l.children = __flaterm_c;
__flaterm_l
};
}
test.rs
use macro_harness::run;
#[test]
fn test_node() {
run("tests/test_nodes.rs");
}
Here is a structure of an example project.
.
├── Cargo.toml
├── src
│ └── lib.rs
└── tests
├── Cargo.template.toml
├── test_nodes.rs
├── test_nodes.stdout
└── test.rs
MACRO_HARNESS=overwrite cargo test
See tests
in flaterm-macro.
- Support glob match
- Stop using
panic!()
on everything - Improve printing result
- CI using GitHub Actions
- Publish to crates.io
- Handle various errors
- Not installed
cargo-expand
crate - Version mismatch of
cargo-expand
(require1.0.8
or later)
- Not installed
MIT
Yuki Kodama / @kuy