{"id":19636262,"url":"https://github.com/kuy/macro-harness","last_synced_at":"2025-07-07T02:36:30.759Z","repository":{"id":42056997,"uuid":"396353139","full_name":"kuy/macro-harness","owner":"kuy","description":"Test harness for procedural macros","archived":false,"fork":false,"pushed_at":"2024-05-05T09:48:23.000Z","size":245,"stargazers_count":7,"open_issues_count":4,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-05-05T10:37:28.428Z","etag":null,"topics":["assert","proc-macro","rust","testing-library"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kuy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-08-15T13:06:50.000Z","updated_at":"2023-03-08T03:44:05.000Z","dependencies_parsed_at":"2023-11-07T05:05:04.961Z","dependency_job_id":"1c3591ab-8985-4ab2-a188-dd932764a006","html_url":"https://github.com/kuy/macro-harness","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kuy%2Fmacro-harness","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kuy%2Fmacro-harness/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kuy%2Fmacro-harness/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kuy%2Fmacro-harness/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kuy","download_url":"https://codeload.github.com/kuy/macro-harness/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224102646,"owners_count":17256222,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["assert","proc-macro","rust","testing-library"],"created_at":"2024-11-11T12:28:28.453Z","updated_at":"2024-11-11T12:28:58.985Z","avatar_url":"https://github.com/kuy.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003emacro-harness\u003c/h1\u003e\n\u003cp align=\"center\"\u003e\n  \u003cb\u003eTest harness for \u003ca href=\"https://doc.rust-lang.org/reference/procedural-macros.html\"\u003eprocedural macros\u003c/a\u003e\u003c/b\u003e\n\u003c/p\u003e\n\n[![CI](https://github.com/kuy/macro-harness/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/kuy/macro-harness/actions/workflows/ci.yml)\n\n![screen](./assets/screen.gif)\n\n## 🚨 UNDERDEVELOPMENT 🚨\n\nWorking on MVP :)\n\n## Usage\n\n### 1. Prepare `Cargo.template.toml` file in `tests` directory\n\nYou can use a relative path to the local dependency.  \nNo need to put `[lib]` section.\n\n```toml\n[package]\nname = \"awesome-project-tests\"\nedition = \"2018\"\npublish = false\n\n[dependencies]\nfutures = \"1\"\nmy-lunatic-dep = { path = \"../../my-lunatic-dep\" }\n```\n\n### 2. Put a pair of source and output files in `tests` directory\n\n`test_nodes.rs`\n\n```rust\nuse flaterm_macro::layout;\n\npub fn test() {\n    layout! {\n        \u003cBlock\u003e\n            \u003cText /\u003e\n        \u003c/Block\u003e\n    };\n}\n```\n\n`test_nodes.stdout`\n\n```rust\n#![feature(prelude_import)]\n#[prelude_import]\nuse std::prelude::rust_2018::*;\n#[macro_use]\nextern crate std;\nuse flaterm_macro::layout;\npub fn test() {\n    {\n        let mut __flaterm_l = ::flaterm::Node::new(::std::string::String::from(\"Block\"));\n        let mut __flaterm_c: ::std::vec::Vec\u003c::flaterm::Node\u003e = ::std::default::Default::default();\n        __flaterm_c.push(::std::convert::Into::into({\n            let mut __flaterm_l = ::flaterm::Node::new(::std::string::String::from(\"Text\"));\n            __flaterm_l\n        }));\n        __flaterm_l.children = __flaterm_c;\n        __flaterm_l\n    };\n}\n```\n\n### 3. Write test file\n\n`test.rs`\n\n```rust\nuse macro_harness::run;\n\n#[test]\nfn test_node() {\n    run(\"tests/test_nodes.rs\");\n}\n```\n\n### 4. Run `cargo test` and get result\n\nHere is a structure of an example project.\n\n```\n.\n├── Cargo.toml\n├── src\n│  └── lib.rs\n└── tests\n   ├── Cargo.template.toml\n   ├── test_nodes.rs\n   ├── test_nodes.stdout\n   └── test.rs\n```\n\n### 5. Use `MACRO_HARNESS=overwrite` environment variable to update `.stdout` files\n\n`MACRO_HARNESS=overwrite cargo test`\n\n## Example\n\nSee [`tests`](https://github.com/kuy/decom/tree/main/flaterm-macro/tests) in [flaterm-macro](https://github.com/kuy/decom/tree/main/flaterm-macro).\n\n## TODOs\n\n- [ ] Support glob match\n- [ ] Stop using `panic!()` on everything\n- [ ] Improve printing result\n- [ ] CI using GitHub Actions\n- [ ] Publish to crates.io\n- [ ] Handle various errors\n  - [ ] Not installed `cargo-expand` crate\n  - [ ] Version mismatch of `cargo-expand` (require `1.0.8` or later)\n\n## License\n\nMIT\n\n## Author\n\nYuki Kodama / [@kuy](https://twitter.com/kuy)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkuy%2Fmacro-harness","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkuy%2Fmacro-harness","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkuy%2Fmacro-harness/lists"}