From 9597966c1d3358a7dbc389177d6854ad89161df0 Mon Sep 17 00:00:00 2001 From: Onur Demirci Date: Mon, 27 Nov 2023 10:03:16 +0100 Subject: [PATCH] feat(CompareCommand): Add the `SEMANTIC_DIFF` as a new compare method The new compare method `SEMANTIC_DIFF` can be used for comparing the ORT results on the object level. Currently, it only checks whether the provided ORT results are equal. There will a improved comparison of the results in the upcoming commit(s). Signed-off-by: Onur Demirci --- .../compare/src/main/kotlin/CompareCommand.kt | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/plugins/commands/compare/src/main/kotlin/CompareCommand.kt b/plugins/commands/compare/src/main/kotlin/CompareCommand.kt index 90417e4e475da..0d545e965a4f0 100644 --- a/plugins/commands/compare/src/main/kotlin/CompareCommand.kt +++ b/plugins/commands/compare/src/main/kotlin/CompareCommand.kt @@ -155,12 +155,27 @@ class CompareCommand : OrtCommand( throw ProgramResult(1) } + + CompareMethod.SEMANTIC_DIFF -> { + echo( + "The '${CompareMethod.SEMANTIC_DIFF}' compare method is not fully implemented. Some properties" + + " may not be taken into account in the comparison." + ) + + if (resultA == resultB) { + echo("The ORT results are the same.") + throw ProgramResult(0) + } + + throw ProgramResult(1) + } } } } private enum class CompareMethod { - TEXT_DIFF + TEXT_DIFF, + SEMANTIC_DIFF } private class InvariantInstantSerializer : StdSerializer(Instant::class.java) {