diff --git a/plugins/commands/compare/src/funTest/assets/semver4j-analyzer-result-linux.yml b/plugins/commands/compare/src/funTest/assets/semver4j-analyzer-result-linux.yml new file mode 100644 index 0000000000000..9bf93dc29067c --- /dev/null +++ b/plugins/commands/compare/src/funTest/assets/semver4j-analyzer-result-linux.yml @@ -0,0 +1,200 @@ +--- +repository: + vcs: + type: "Git" + url: "https://github.com/vdurmont/semver4j.git" + revision: "7653e418d610ffcd2811bcb55fd72d00d420950b" + path: "" + vcs_processed: + type: "Git" + url: "https://github.com/vdurmont/semver4j.git" + revision: "7653e418d610ffcd2811bcb55fd72d00d420950b" + path: "" + config: {} +analyzer: + start_time: "2023-11-22T08:58:09.135241769Z" + end_time: "2023-11-22T08:58:10.352015597Z" + environment: + ort_version: "1e4a20cf64" + java_version: "17.0.8.1" + os: "Linux" + processors: 20 + max_memory: 8325693440 + variables: + JAVA_HOME: "/opt/java/openjdk" + ANDROID_HOME: "/opt/android-sdk" + GOPATH: "/tmp/go" + tool_versions: {} + config: + allow_dynamic_versions: false + skip_excluded: false + result: + projects: + - id: "Maven:com.vdurmont:semver4j:3.1.0" + definition_file_path: "pom.xml" + authors: + - "Vincent DURMONT" + declared_licenses: + - "The MIT License" + declared_licenses_processed: + spdx_expression: "MIT" + mapped: + The MIT License: "MIT" + vcs: + type: "Git" + url: "git@github.com:vdurmont/semver4j.git" + revision: "" + path: "" + vcs_processed: + type: "Git" + url: "https://github.com/vdurmont/semver4j.git" + revision: "7653e418d610ffcd2811bcb55fd72d00d420950b" + path: "" + homepage_url: "https://github.com/vdurmont/semver4j" + scope_names: + - "test" + packages: + - id: "Maven:junit:junit:4.12" + purl: "pkg:maven/junit/junit@4.12" + authors: + - "David Saff" + - "JUnit" + - "Kevin Cooney" + - "Marc Philipp" + - "Stefan Birkner" + declared_licenses: + - "Eclipse Public License 1.0" + declared_licenses_processed: + spdx_expression: "EPL-1.0" + mapped: + Eclipse Public License 1.0: "EPL-1.0" + description: "JUnit is a unit testing framework for Java, created by Erich Gamma\ + \ and Kent Beck." + homepage_url: "http://junit.org" + binary_artifact: + url: "https://repo.maven.apache.org/maven2/junit/junit/4.12/junit-4.12.jar" + hash: + value: "2973d150c0dc1fefe998f834810d68f278ea58ec" + algorithm: "SHA-1" + source_artifact: + url: "https://repo.maven.apache.org/maven2/junit/junit/4.12/junit-4.12-sources.jar" + hash: + value: "a6c32b40bf3d76eca54e3c601e5d1470c86fcdfa" + algorithm: "SHA-1" + vcs: + type: "Git" + url: "git://github.com/junit-team/junit.git" + revision: "r4.12" + path: "" + vcs_processed: + type: "Git" + url: "https://github.com/junit-team/junit.git" + revision: "r4.12" + path: "" + - id: "Maven:org.hamcrest:hamcrest-core:1.3" + purl: "pkg:maven/org.hamcrest/hamcrest-core@1.3" + authors: + - "Joe Walnes" + - "Nat Pryce" + - "Neil Dunn" + - "Steve Freeman" + - "Tom Denley" + declared_licenses: + - "New BSD License" + declared_licenses_processed: + spdx_expression: "BSD-3-Clause" + mapped: + New BSD License: "BSD-3-Clause" + description: "This is the core API of hamcrest matcher framework to be used\ + \ by third-party framework providers. This includes the a foundation set of\ + \ matcher implementations for common operations." + homepage_url: "https://github.com/hamcrest/JavaHamcrest/hamcrest-core" + binary_artifact: + url: "https://repo.maven.apache.org/maven2/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar" + hash: + value: "42a25dc3219429f0e5d060061f71acb49bf010a0" + algorithm: "SHA-1" + source_artifact: + url: "https://repo.maven.apache.org/maven2/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3-sources.jar" + hash: + value: "1dc37250fbc78e23a65a67fbbaf71d2e9cbc3c0b" + algorithm: "SHA-1" + vcs: + type: "Git" + url: "git@github.com:hamcrest/JavaHamcrest.git" + revision: "" + path: "" + vcs_processed: + type: "Git" + url: "ssh://git@github.com/hamcrest/JavaHamcrest.git" + revision: "" + path: "" + - id: "Maven:org.mockito:mockito-all:1.10.19" + purl: "pkg:maven/org.mockito/mockito-all@1.10.19" + authors: + - "Szczepan Faber" + declared_licenses: + - "The MIT License" + declared_licenses_processed: + spdx_expression: "MIT" + mapped: + The MIT License: "MIT" + description: "Mock objects library for java" + homepage_url: "http://www.mockito.org" + binary_artifact: + url: "https://repo.maven.apache.org/maven2/org/mockito/mockito-all/1.10.19/mockito-all-1.10.19.jar" + hash: + value: "539df70269cc254a58cccc5d8e43286b4a73bf30" + algorithm: "SHA-1" + source_artifact: + url: "https://repo.maven.apache.org/maven2/org/mockito/mockito-all/1.10.19/mockito-all-1.10.19-sources.jar" + hash: + value: "8269667b73d9616600359a9b0ba1b1c7d0cf7a97" + algorithm: "SHA-1" + vcs: + type: "" + url: "" + revision: "" + path: "" + vcs_processed: + type: "Git" + url: "https://github.com/mockito/mockito.git" + revision: "" + path: "" + dependency_graphs: + Maven: + packages: + - "Maven:junit:junit:4.12" + - "Maven:org.hamcrest:hamcrest-core:1.3" + - "Maven:org.mockito:mockito-all:1.10.19" + scopes: + com.vdurmont:semver4j:3.1.0:test: + - root: 0 + - root: 2 + nodes: + - pkg: 1 + - {} + - pkg: 2 + edges: + - from: 1 + to: 0 +scanner: null +advisor: null +evaluator: null +resolved_configuration: + package_curations: + - provider: + id: "DefaultFile" + curations: [] + - provider: + id: "DefaultDir" + curations: [] + - provider: + id: "ClearlyDefined" + curations: + - id: "Maven:org.hamcrest:hamcrest-core:1.3" + curations: + concluded_license: "BSD-3-Clause" + - id: "Maven:org.mockito:mockito-all:1.10.19" + curations: + concluded_license: "MIT" diff --git a/plugins/commands/compare/src/funTest/assets/semver4j-analyzer-result-windows.yml b/plugins/commands/compare/src/funTest/assets/semver4j-analyzer-result-windows.yml new file mode 100644 index 0000000000000..22ce0306e48d9 --- /dev/null +++ b/plugins/commands/compare/src/funTest/assets/semver4j-analyzer-result-windows.yml @@ -0,0 +1,202 @@ +--- +repository: + vcs: + type: "Git" + url: "https://github.com/vdurmont/semver4j.git" + revision: "7653e418d610ffcd2811bcb55fd72d00d420950b" + path: "" + vcs_processed: + type: "Git" + url: "https://github.com/vdurmont/semver4j.git" + revision: "7653e418d610ffcd2811bcb55fd72d00d420950b" + path: "" + config: {} +analyzer: + start_time: "2023-11-28T18:19:25.524660Z" + end_time: "2023-11-28T18:19:28.667949Z" + environment: + ort_version: "IDE-SNAPSHOT" + java_version: "17.0.9" + os: "Windows 11" + processors: 20 + max_memory: 8506048512 + variables: + USERPROFILE: "C:\\Users\\Sebastian" + OS: "Windows_NT" + COMSPEC: "C:\\WINDOWS\\system32\\cmd.exe" + JAVA_HOME: "C:\\Users\\Sebastian\\.jdks\\temurin-17.0.6" + ANDROID_HOME: "C:\\Users\\Sebastian\\AppData\\Local\\Android\\Sdk" + tool_versions: {} + config: + allow_dynamic_versions: false + skip_excluded: false + result: + projects: + - id: "Maven:com.vdurmont:semver4j:3.1.0" + definition_file_path: "pom.xml" + authors: + - "Vincent DURMONT" + declared_licenses: + - "The MIT License" + declared_licenses_processed: + spdx_expression: "MIT" + mapped: + The MIT License: "MIT" + vcs: + type: "Git" + url: "git@github.com:vdurmont/semver4j.git" + revision: "" + path: "" + vcs_processed: + type: "Git" + url: "https://github.com/vdurmont/semver4j.git" + revision: "7653e418d610ffcd2811bcb55fd72d00d420950b" + path: "" + homepage_url: "https://github.com/vdurmont/semver4j" + scope_names: + - "test" + packages: + - id: "Maven:junit:junit:4.12" + purl: "pkg:maven/junit/junit@4.12" + authors: + - "David Saff" + - "JUnit" + - "Kevin Cooney" + - "Marc Philipp" + - "Stefan Birkner" + declared_licenses: + - "Eclipse Public License 1.0" + declared_licenses_processed: + spdx_expression: "EPL-1.0" + mapped: + Eclipse Public License 1.0: "EPL-1.0" + description: "JUnit is a unit testing framework for Java, created by Erich Gamma\ + \ and Kent Beck." + homepage_url: "http://junit.org" + binary_artifact: + url: "https://repo.maven.apache.org/maven2/junit/junit/4.12/junit-4.12.jar" + hash: + value: "2973d150c0dc1fefe998f834810d68f278ea58ec" + algorithm: "SHA-1" + source_artifact: + url: "https://repo.maven.apache.org/maven2/junit/junit/4.12/junit-4.12-sources.jar" + hash: + value: "a6c32b40bf3d76eca54e3c601e5d1470c86fcdfa" + algorithm: "SHA-1" + vcs: + type: "Git" + url: "git://github.com/junit-team/junit.git" + revision: "r4.12" + path: "" + vcs_processed: + type: "Git" + url: "https://github.com/junit-team/junit.git" + revision: "r4.12" + path: "" + - id: "Maven:org.hamcrest:hamcrest-core:1.3" + purl: "pkg:maven/org.hamcrest/hamcrest-core@1.3" + authors: + - "Joe Walnes" + - "Nat Pryce" + - "Neil Dunn" + - "Steve Freeman" + - "Tom Denley" + declared_licenses: + - "New BSD License" + declared_licenses_processed: + spdx_expression: "BSD-3-Clause" + mapped: + New BSD License: "BSD-3-Clause" + description: "This is the core API of hamcrest matcher framework to be used\ + \ by third-party framework providers. This includes the a foundation set of\ + \ matcher implementations for common operations." + homepage_url: "https://github.com/hamcrest/JavaHamcrest/hamcrest-core" + binary_artifact: + url: "https://repo.maven.apache.org/maven2/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar" + hash: + value: "42a25dc3219429f0e5d060061f71acb49bf010a0" + algorithm: "SHA-1" + source_artifact: + url: "https://repo.maven.apache.org/maven2/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3-sources.jar" + hash: + value: "1dc37250fbc78e23a65a67fbbaf71d2e9cbc3c0b" + algorithm: "SHA-1" + vcs: + type: "Git" + url: "git@github.com:hamcrest/JavaHamcrest.git" + revision: "" + path: "" + vcs_processed: + type: "Git" + url: "ssh://git@github.com/hamcrest/JavaHamcrest.git" + revision: "" + path: "" + - id: "Maven:org.mockito:mockito-all:1.10.19" + purl: "pkg:maven/org.mockito/mockito-all@1.10.19" + authors: + - "Szczepan Faber" + declared_licenses: + - "The MIT License" + declared_licenses_processed: + spdx_expression: "MIT" + mapped: + The MIT License: "MIT" + description: "Mock objects library for java" + homepage_url: "http://www.mockito.org" + binary_artifact: + url: "https://repo.maven.apache.org/maven2/org/mockito/mockito-all/1.10.19/mockito-all-1.10.19.jar" + hash: + value: "539df70269cc254a58cccc5d8e43286b4a73bf30" + algorithm: "SHA-1" + source_artifact: + url: "https://repo.maven.apache.org/maven2/org/mockito/mockito-all/1.10.19/mockito-all-1.10.19-sources.jar" + hash: + value: "8269667b73d9616600359a9b0ba1b1c7d0cf7a97" + algorithm: "SHA-1" + vcs: + type: "" + url: "" + revision: "" + path: "" + vcs_processed: + type: "Git" + url: "https://github.com/mockito/mockito.git" + revision: "" + path: "" + dependency_graphs: + Maven: + packages: + - "Maven:junit:junit:4.12" + - "Maven:org.hamcrest:hamcrest-core:1.3" + - "Maven:org.mockito:mockito-all:1.10.19" + scopes: + com.vdurmont:semver4j:3.1.0:test: + - root: 0 + - root: 2 + nodes: + - pkg: 1 + - {} + - pkg: 2 + edges: + - from: 1 + to: 0 +scanner: null +advisor: null +evaluator: null +resolved_configuration: + package_curations: + - provider: + id: "DefaultFile" + curations: [] + - provider: + id: "DefaultDir" + curations: [] + - provider: + id: "ClearlyDefined" + curations: + - id: "Maven:org.hamcrest:hamcrest-core:1.3" + curations: + concluded_license: "BSD-3-Clause" + - id: "Maven:org.mockito:mockito-all:1.10.19" + curations: + concluded_license: "MIT" diff --git a/plugins/commands/compare/src/funTest/kotlin/CompareCommandFunTest.kt b/plugins/commands/compare/src/funTest/kotlin/CompareCommandFunTest.kt new file mode 100644 index 0000000000000..beb100c249ae1 --- /dev/null +++ b/plugins/commands/compare/src/funTest/kotlin/CompareCommandFunTest.kt @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2023 The ORT Project Authors (see ) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * License-Filename: LICENSE + */ + +package org.ossreviewtoolkit.plugins.commands.compare + +import com.github.ajalt.clikt.testing.test + +import io.kotest.assertions.withClue +import io.kotest.core.spec.style.WordSpec +import io.kotest.matchers.shouldBe + +class CompareCommandFunTest : WordSpec({ + "The text diff method" should { + "ignore time and environment differences in an analyzer result" { + val result = CompareCommand().test( + arrayOf( + "--method=TEXT_DIFF", + "--ignore-time", + "--ignore-environment", + "src/funTest/assets/semver4j-analyzer-result-linux.yml", + "src/funTest/assets/semver4j-analyzer-result-windows.yml" + ) + ) + + withClue(result.stdout) { + result.statusCode shouldBe 0 + } + } + } +})