Skip to content

Commit

Permalink
Replace code coverage crate with maintained upstream alternative
Browse files Browse the repository at this point in the history
  • Loading branch information
csnover authored and Urist-McGit committed Nov 27, 2024
1 parent 4d7bb7f commit 3b04c65
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 25 deletions.
2 changes: 1 addition & 1 deletion binrw_derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ quote = "1.0.0"
syn = { version = "2", features = ["extra-traits", "fold", "full", "visit"] }

[dev-dependencies]
runtime-macros-derive = "0.4.0"
runtime-macros = "1.1.0"

[features]
default = []
Expand Down
50 changes: 28 additions & 22 deletions binrw_derive/src/binrw/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ fn parse(
#[cfg_attr(coverage_nightly, coverage(off))]
#[test]
fn derive_binread_code_coverage_for_tool() {
use runtime_macros_derive::emulate_derive_expansion_fallible;
use runtime_macros::emulate_derive_macro_expansion;
use std::{env, fs};

let derive_tests_folder = env::current_dir()
Expand All @@ -195,16 +195,19 @@ fn derive_binread_code_coverage_for_tool() {
let entry = entry.unwrap();
if entry.file_type().unwrap().is_file() {
let file = fs::File::open(entry.path()).unwrap();
if emulate_derive_expansion_fallible(file, "BinRead", |input| {
parse(
&input,
Options {
derive: true,
write: false,
},
)
.1
})
if emulate_derive_macro_expansion(
file,
&[("BinRead", |input| {
parse(
&syn::parse2::<syn::DeriveInput>(input).unwrap(),
Options {
derive: true,
write: false,
},
)
.1
})],
)
.is_err()
{
run_success = false;
Expand All @@ -219,7 +222,7 @@ fn derive_binread_code_coverage_for_tool() {
#[cfg_attr(coverage_nightly, coverage(off))]
#[test]
fn derive_binwrite_code_coverage_for_tool() {
use runtime_macros_derive::emulate_derive_expansion_fallible;
use runtime_macros::emulate_derive_macro_expansion;
use std::{env, fs};

let derive_tests_folder = env::current_dir()
Expand All @@ -235,16 +238,19 @@ fn derive_binwrite_code_coverage_for_tool() {
let entry = entry.unwrap();
if entry.file_type().unwrap().is_file() {
let file = fs::File::open(entry.path()).unwrap();
if emulate_derive_expansion_fallible(file, "BinWrite", |input| {
parse(
&input,
Options {
derive: true,
write: true,
},
)
.1
})
if emulate_derive_macro_expansion(
file,
&[("BinWrite", |input| {
parse(
&syn::parse2::<syn::DeriveInput>(input).unwrap(),
Options {
derive: true,
write: true,
},
)
.1
})],
)
.is_err()
{
run_success = false;
Expand Down
10 changes: 8 additions & 2 deletions binrw_derive/src/named_args/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,15 @@ mod kw {
#[cfg_attr(coverage_nightly, coverage(off))]
#[test]
fn derive_named_args_code_coverage_for_tool() {
use runtime_macros_derive::emulate_derive_expansion_fallible;
use runtime_macros::emulate_derive_macro_expansion;
let file = std::fs::File::open("../binrw/tests/named_args.rs").unwrap();
emulate_derive_expansion_fallible(file, "NamedArgs", |input| derive_from_input(input)).unwrap();
emulate_derive_macro_expansion(
file,
&[("NamedArgs", |input| {
derive_from_input(syn::parse2::<syn::DeriveInput>(input).unwrap())
})],
)
.unwrap();
}

#[cfg(test)]
Expand Down

0 comments on commit 3b04c65

Please sign in to comment.