Search in sources :

Example 1 with TestCategory

use of org.lflang.tests.TestRegistry.TestCategory in project lingua-franca by lf-lang.

the class LspTests method selectTests.

/**
 * Select {@code count} tests from each test category.
 * @param target The target language of the desired tests.
 * @return A sample of one integration test per target, per category.
 */
private Set<LFTest> selectTests(Target target) {
    Set<LFTest> ret = new HashSet<>();
    for (TestCategory category : selectedCategories()) {
        Set<LFTest> registeredTests = TestRegistry.getRegisteredTests(target, category, false);
        if (registeredTests.size() == 0)
            continue;
        int relativeIndex = RANDOM.nextInt(registeredTests.size());
        for (LFTest t : registeredTests) {
            if (relativeIndex-- == 0) {
                ret.add(t);
                break;
            }
        }
    }
    return ret;
}
Also used : TestCategory(org.lflang.tests.TestRegistry.TestCategory) LFTest(org.lflang.tests.LFTest) HashSet(java.util.HashSet)

Example 2 with TestCategory

use of org.lflang.tests.TestRegistry.TestCategory in project lingua-franca by lf-lang.

the class CSchedulerTest method runWithNonDefaultSchedulers.

/**
 * Swap the default runtime scheduler with other supported versions and
 * run all the supported tests. Only run tests for a specific non-default
 * scheduler if specified using a system property (e.g., -Dscheduler=GEDF_NP).
 */
@Test
public void runWithNonDefaultSchedulers() {
    EnumSet<TestCategory> categories = EnumSet.of(TestCategory.CONCURRENT, TestCategory.MULTIPORT);
    // Add federated and docker tests if supported
    if (!isWindows()) {
        categories.add(TestCategory.FEDERATED);
        if (isLinux()) {
            categories.add(TestCategory.DOCKER_FEDERATED);
        }
    }
    var name = System.getProperty("scheduler");
    if (name != null) {
        var option = EnumSet.allOf(SchedulerOption.class).stream().filter(it -> it.name().equals(name)).findFirst();
        if (option.isPresent()) {
            this.runTest(option.get(), categories);
        } else {
            throw new RuntimeException("Cannot find runtime scheduler called " + name);
        }
    } else {
        for (SchedulerOption scheduler : EnumSet.allOf(SchedulerOption.class)) {
            if (scheduler == SchedulerOption.getDefault())
                continue;
            this.runTest(scheduler, categories);
        }
    }
}
Also used : Test(org.junit.jupiter.api.Test) SchedulerOption(org.lflang.TargetProperty.SchedulerOption) Target(org.lflang.Target) TestCategory(org.lflang.tests.TestRegistry.TestCategory) TestBase(org.lflang.tests.TestBase) EnumSet(java.util.EnumSet) Configurators(org.lflang.tests.Configurators) TestCategory(org.lflang.tests.TestRegistry.TestCategory) SchedulerOption(org.lflang.TargetProperty.SchedulerOption) Test(org.junit.jupiter.api.Test)

Aggregations

TestCategory (org.lflang.tests.TestRegistry.TestCategory)2 EnumSet (java.util.EnumSet)1 HashSet (java.util.HashSet)1 Test (org.junit.jupiter.api.Test)1 Target (org.lflang.Target)1 SchedulerOption (org.lflang.TargetProperty.SchedulerOption)1 Configurators (org.lflang.tests.Configurators)1 LFTest (org.lflang.tests.LFTest)1 TestBase (org.lflang.tests.TestBase)1