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

include fast, verbose, keyPattern, showDatafile and onlyFailures options in command #7

Merged
merged 3 commits into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@ jobs:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle.kts') }}
restore-keys: |
${{ runner.os }}-gradle-
${{ runner.os }}-gradle-

- name: Build with Gradle
env:
GITHUB_ACTOR: ${{ secrets.GITHUB_ACTOR }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./gradlew build

- name: Test with Gradle
Expand Down
11 changes: 9 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ plugins {

repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
maven {
url = uri("https://maven.pkg.github.com/featurevisor/featurevisor-kotlin")
credentials {
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
}
}
}

publishing {
Expand All @@ -34,13 +40,14 @@ gradlePlugin {

dependencies {
testImplementation("org.jetbrains.kotlin:kotlin-test")
implementation("com.github.featurevisor:featurevisor-kotlin:0.0.7")
implementation("com.featurevisor:featurevisor-kotlin:0.0.8")
implementation(gradleApi())
}

tasks.test {
useJUnitPlatform()
}

kotlin {
jvmToolchain(17)
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,6 @@ import org.gradle.api.Project

class TestRunnerPlugin : Plugin<Project> {
override fun apply(project: Project) {

project.tasks.register(RunAllTestsTask.NAME,RunAllTestsTask::class.java){ task ->
task.rootProjectPath = project.findProperty("rootProjectPath") as? String
task.testDirPath = project.findProperty("testDirPath") as? String
task.featureName = project.findProperty("featureName") as? String
task.segmentName = project.findProperty("segmentName") as? String
}

project.tasks.register(RunAllTestsTask.NAME,RunAllTestsTask::class.java)
}
}
77 changes: 36 additions & 41 deletions src/main/kotlin/com/featurevisor/tasks/RunAllTestsTask.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,67 +2,62 @@ package com.featurevisor.tasks

import org.gradle.api.DefaultTask
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.Optional
import org.gradle.api.tasks.TaskAction
import com.featurevisor.testRunner.*
import org.gradle.api.tasks.options.Option

open class RunAllTestsTask : DefaultTask() {

companion object {
const val NAME = "run-test"
const val NAME = "test"
}

@Input
@Optional
var rootProjectPath: String? = null
@Option(option = "rootProjectPath", description = "Whether to run test for specific project")
var rootProjectPath: String = project.projectDir.absolutePath

@Input
@Optional
var testDirPath: String? = null
@Option(option = "testDirPath", description = "Whether to run test for specific test directory")
var testDirPath: String = "tests"

@Input
@Optional
var featureName: String? = null
@Option(option = "keyPattern", description = "Run test for specific key pattern")
var keyPattern: String = ""

@Input
@Optional
var segmentName: String? = null
@Option(option = "assertionPattern", description = "Run test for specific assertion pattern")
var assertionPattern: String = ""

@TaskAction
fun executeTask() {

when {
(rootProjectPath.isNullOrEmpty().not() && testDirPath.isNullOrEmpty().not()) -> {
startTest(rootProjectPath.orEmpty(), testDirPath.orEmpty())
}

(rootProjectPath.isNullOrEmpty().not() && featureName.isNullOrEmpty().not()) -> {
testSingleFeature(featureKey = featureName.orEmpty(), projectRootPath = rootProjectPath.orEmpty())
}

(rootProjectPath.isNullOrEmpty().not() && segmentName.isNullOrEmpty().not()) -> {
testSingleSegment(segmentKey = segmentName.orEmpty(), projectRootPath = rootProjectPath.orEmpty())
}
@Input
@Option(option = "verbose", description = "Whether to run tests in verbose mode")
var verbose: Boolean = false

rootProjectPath.isNullOrEmpty().not() -> {
startTest(projectRootPath = rootProjectPath.orEmpty())
}
@Input
@Option(option = "showDatafile", description = "Whether to run tests by showing datafile")
var showDatafile: Boolean = false

testDirPath.isNullOrEmpty().not() -> {
startTest(testDirPath = testDirPath.orEmpty(), projectRootPath = project.projectDir.absolutePath)
}
@Input
@Option(option = "onlyFailures", description = "Whether to run tests by showing only failed tests")
var onlyFailures: Boolean = false

featureName.isNullOrEmpty().not() -> {
testSingleFeature(featureKey = featureName.orEmpty(), projectRootPath = project.projectDir.absolutePath)
}
@Input
@Option(option = "fast", description = "Whether to run tests in fast mode")
var fast: Boolean = false

segmentName.isNullOrEmpty().not() -> {
testSingleSegment(segmentKey = segmentName.orEmpty(), projectRootPath = project.projectDir.absolutePath)
}
@TaskAction
fun executeTask() {

else -> {
startTest(projectRootPath = project.projectDir.absolutePath)
}
}
val testProjectOption = TestProjectOption(
keyPattern = keyPattern,
assertionPattern = assertionPattern,
verbose = verbose,
showDatafile = showDatafile,
onlyFailures = onlyFailures,
fast = fast,
projectRootPath = rootProjectPath,
testDirPath = testDirPath
)

startTest(testProjectOption)
}
}
Loading