From d13cbeb7e18a429ff8f3c19ea25f78b279cb030b Mon Sep 17 00:00:00 2001 From: Tanmay Ranjan <42682768+Tan108@users.noreply.github.com> Date: Mon, 5 Aug 2024 11:43:25 +0530 Subject: [PATCH] Test Runner failed in case of invalid Semver version issue fixes (#49) --- src/main/kotlin/com/featurevisor/sdk/Conditions.kt | 6 +++++- src/main/kotlin/com/featurevisor/sdk/Instance+Evaluation.kt | 6 ++---- src/main/kotlin/com/featurevisor/testRunner/TestExecuter.kt | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/com/featurevisor/sdk/Conditions.kt b/src/main/kotlin/com/featurevisor/sdk/Conditions.kt index 2bda4ec..0245c40 100644 --- a/src/main/kotlin/com/featurevisor/sdk/Conditions.kt +++ b/src/main/kotlin/com/featurevisor/sdk/Conditions.kt @@ -142,6 +142,10 @@ object Conditions { } private fun compareVersions(actual: String, condition: String): Int { - return SemVer.parse(actual).compareTo(SemVer.parse(condition)) + return try { + SemVer.parse(actual).compareTo(SemVer.parse(condition)) + } catch (e: Exception) { + 0 + } } } diff --git a/src/main/kotlin/com/featurevisor/sdk/Instance+Evaluation.kt b/src/main/kotlin/com/featurevisor/sdk/Instance+Evaluation.kt index 0946458..9e3cef9 100644 --- a/src/main/kotlin/com/featurevisor/sdk/Instance+Evaluation.kt +++ b/src/main/kotlin/com/featurevisor/sdk/Instance+Evaluation.kt @@ -220,10 +220,9 @@ fun FeaturevisorInstance.evaluateVariation(featureKey: FeatureKey, context: Cont evaluation = Evaluation( featureKey = featureKey, reason = ERROR, - error(e) ) - this.logger?.error("error", evaluation.toDictionary()) + this.logger?.error(message = e.message.orEmpty(), details = evaluation.toDictionary()) return evaluation } @@ -433,10 +432,9 @@ fun FeaturevisorInstance.evaluateFlag(featureKey: FeatureKey, context: Context = evaluation = Evaluation( featureKey = featureKey, reason = ERROR, - error(e) ) - this.logger?.error("error", evaluation.toDictionary()) + this.logger?.error(message = e.message.orEmpty(), details = evaluation.toDictionary()) return evaluation } diff --git a/src/main/kotlin/com/featurevisor/testRunner/TestExecuter.kt b/src/main/kotlin/com/featurevisor/testRunner/TestExecuter.kt index b2e9f69..4ce8844 100644 --- a/src/main/kotlin/com/featurevisor/testRunner/TestExecuter.kt +++ b/src/main/kotlin/com/featurevisor/testRunner/TestExecuter.kt @@ -41,7 +41,7 @@ fun startTest(option: TestProjectOption) { try { executionResult = executeTest(filePath, dataFile = datafile, option) } catch (e: Exception) { - printMessageInRedColor("Exception in $filePath --> ${e.message}") + printMessageInRedColor("Exception while execution test --> ${e.message}") } if (executionResult == null) {