From fedd9e0707df391524db4e105a69956b6215f13a Mon Sep 17 00:00:00 2001 From: dgelessus <dgelessus@users.noreply.github.com> Date: Wed, 15 Jan 2025 13:02:01 +0100 Subject: [PATCH] Try to enable parallel test running for all tests except JS tests --- .gitlab-ci.yml | 2 +- build.gradle | 34 +++++++++++++++++++++++++++++----- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e2c06c325..5ce615fd0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -37,4 +37,4 @@ test:linux: - mkdir cpp_build && cd cpp_build - cmake .. - make install & cd .. - - ./gradlew test --info --stacktrace + - ./gradlew check --info --stacktrace diff --git a/build.gradle b/build.gradle index 8fd51fa97..18639151c 100644 --- a/build.gradle +++ b/build.gradle @@ -42,19 +42,43 @@ application { mainClass = 'de.hhu.stups.codegenerator.CodeGenerator' } +// The JavaScript tests currently cannot run in parallel, +// because multiple tests copy files to the same location and conflict with each other. +final noParallelTests = [ + "de.hhu.stups.codegenerator.js.*", +] + test { - // We could enable executing tests in parallel, as recommended here: + // Execute tests in parallel where possible, as recommended here: // https://docs.gradle.org/8.12/userguide/performance.html#execute_tests_in_parallel - // But this currently doesn't work with the JavaScript tests, - // because multiple tests copy files to the same location and conflict with each other. - //maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1 + maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1 + + filter { + excludePatterns += noParallelTests + } +} + +final testNoParallel = tasks.register("testNoParallel", Test) { + description = "Runs tests that cannot be executed in parallel." + group = "verification" + + testClassesDirs = sourceSets.test.output.classesDirs + classpath = sourceSets.test.runtimeClasspath + filter { + includePatterns += noParallelTests + } +} +tasks.named("check").configure { + dependsOn += [testNoParallel] +} + +tasks.withType(Test).configureEach { testLogging { events += [TestLogEvent.PASSED] } } - jar { manifest { attributes( -- GitLab