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;
}
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);
}
}
}
Aggregations