From e5384bfdcb053a1845ca7e95e0caad6c79eecaa5 Mon Sep 17 00:00:00 2001 From: Tanmay Ranjan Date: Sun, 4 Aug 2024 15:24:29 +0530 Subject: [PATCH] Test Runner failed in case of invalid semver version issue fixes --- 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) {