Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@ExcludeClassNamePatterns programmatically #3346

Open
sdelamo opened this issue Jun 8, 2023 · 1 comment
Open

@ExcludeClassNamePatterns programmatically #3346

sdelamo opened this issue Jun 8, 2023 · 1 comment

Comments

@sdelamo
Copy link

sdelamo commented Jun 8, 2023

I have a Test Suite which needs to exclude different tests depending on a condition.

I would like to be able provide a list of patterns programmatically. It would be great if I could provide a class which provides the exclusion class name patterns.

Something like:

@ExcludeClassNamePatternsProvider(ExcludeClassNamePatternsProviderImpl.class)
@Suite
@FunctionalInterface
interface ExcludeClassNamePatternsProvider {
String[] excludeClassNamePatterns()
}
package io.micronaut.http.server.tck.jetty.tests;

import java.util.Locale;

public class ExcludeClassNamePatternsProviderImpl implements ExcludeClassNamePatternsProvider {
    @Override
    public String[] excludeClasNamePatterns() {
        if (isGraalJVM()) {
            return new String[] {
                "io.micronaut.http.server.tck.tests.staticresources.StaticResourceTest",
                "io.micronaut.http.server.tck.tests.filter.ClientResponseFilterTest",
                "io.micronaut.http.server.tck.tests.StreamTest",
                "io.micronaut.http.server.tck.tests.codec.JsonCodeAdditionalTypeTest"
            };
        }
        return new String[] {
            "io.micronaut.http.server.tck.tests.StreamTest",
                "io.micronaut.http.server.tck.tests.codec.JsonCodeAdditionalTypeTest"
        };
    }
    
    public static boolean isGraalJVM() {
        return isGraal("jvmci.Compiler", "java.vendor.version", "java.vendor");
    }

    private static boolean isGraal(String... props) {
        for (String prop : props) {
            String vv = System.getProperty(prop);
            if (vv != null && vv.toLowerCase(Locale.ENGLISH).contains("graal")) {
                return true;
            }
        }
        return false;
    }
}

is there anyway to do this?

@sbrannen
Copy link
Member

sbrannen commented Jun 9, 2023

is there anyway to do this?

No, there is currently no way to achieve that programmatically for a @Suite class.

At the moment, annotation-based suites are 100% declarative.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants