Skip to content

Commit

Permalink
Merge pull request wasmerio#2403 from Hywan/test-avoid-unused-warning…
Browse files Browse the repository at this point in the history
…-for-autotests

test: Add #[allow(unused)] when no compiler is set.
  • Loading branch information
syrusakbary authored Jun 7, 2021
2 parents 0342e7e + aef72da commit c98d3a8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 20 deletions.
1 change: 1 addition & 0 deletions tests/lib/compiler-test-derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ pub fn compiler_test(attrs: TokenStream, input: TokenStream) -> TokenStream {
mod #fn_name {
use super::*;

#[allow(unused)]
#my_fn

#singlepass_compiler_test
Expand Down
34 changes: 14 additions & 20 deletions tests/lib/compiler-test-derive/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,23 @@ macro_rules! gen_tests {(
) => (
$(
#[test]
fn $test_name ()
fn $test_name()
{
let input: TokenStream =
stringify!($($input)*)
.parse()
.expect("Syntax error in test")
;
.expect("Syntax error in test");
let output: TokenStream =
$output
.parse()
.expect("Syntax error in test")
;
.expect("Syntax error in test");
let attrs: TokenStream =
stringify!($($($attrs)*)?)
.parse()
.expect("Syntax error in test");
let ret = $function(attrs, input).to_string();
eprintln!("{}", ret);
assert_eq!(
ret,
output.to_string(),
)
assert_eq!(ret, output.to_string());
}
)*
)}
Expand All @@ -43,17 +38,16 @@ gen_tests! {
stringify! {
#[compiler_test(derive_test)]
#[cold]
fn add (config: crate::Config)
{
fn foo(config: crate::Config) {
// Do tests
}
} == stringify! {
#[cfg(test)]
mod add {
mod foo {
use super::*;

fn add(config: crate::Config)
{
#[allow(unused)]
fn foo(config: crate::Config) {
// Do tests
}

Expand All @@ -64,7 +58,7 @@ gen_tests! {
#[cold]
#[cfg(feature = "universal")]
fn universal() {
add(crate::Config::new(
foo(crate::Config::new(
crate::Engine::Universal,
crate::Compiler::Singlepass
))
Expand All @@ -73,7 +67,7 @@ gen_tests! {
#[cold]
#[cfg(feature = "dylib")]
fn dylib() {
add(crate::Config::new(
foo(crate::Config::new(
crate::Engine::Dylib,
crate::Compiler::Singlepass
))
Expand All @@ -87,7 +81,7 @@ gen_tests! {
#[cold]
#[cfg(feature = "universal")]
fn universal() {
add(crate::Config::new(
foo(crate::Config::new(
crate::Engine::Universal,
crate::Compiler::Cranelift
))
Expand All @@ -96,7 +90,7 @@ gen_tests! {
#[cold]
#[cfg(feature = "dylib")]
fn dylib() {
add(crate::Config::new(
foo(crate::Config::new(
crate::Engine::Dylib,
crate::Compiler::Cranelift
))
Expand All @@ -110,7 +104,7 @@ gen_tests! {
#[cold]
#[cfg(feature = "universal")]
fn universal() {
add(crate::Config::new(
foo(crate::Config::new(
crate::Engine::Universal,
crate::Compiler::LLVM
))
Expand All @@ -119,7 +113,7 @@ gen_tests! {
#[cold]
#[cfg(feature = "dylib")]
fn dylib() {
add(crate::Config::new(
foo(crate::Config::new(
crate::Engine::Dylib,
crate::Compiler::LLVM
))
Expand Down

0 comments on commit c98d3a8

Please sign in to comment.