From fef241479dfb610597dd39c535e635c95699d58e Mon Sep 17 00:00:00 2001 From: Nicolas Nobelis Date: Wed, 24 Jul 2024 11:29:38 +0200 Subject: [PATCH] chore(Bazel): replace the test done by `BazelTest` by a functional test Please note that no information could be found for the `glog` module because of https://github.com/oss-review-toolkit/ort/issues/8801. Signed-off-by: Nicolas Nobelis --- .../bazel-expected-output-local-registry.yml | 108 ++++++++++++++++++ .../bazel/src/funTest/kotlin/BazelFunTest.kt | 9 ++ .../bazel/src/test/kotlin/BazelTest.kt | 46 -------- 3 files changed, 117 insertions(+), 46 deletions(-) create mode 100644 plugins/package-managers/bazel/src/funTest/assets/projects/synthetic/bazel-expected-output-local-registry.yml delete mode 100644 plugins/package-managers/bazel/src/test/kotlin/BazelTest.kt diff --git a/plugins/package-managers/bazel/src/funTest/assets/projects/synthetic/bazel-expected-output-local-registry.yml b/plugins/package-managers/bazel/src/funTest/assets/projects/synthetic/bazel-expected-output-local-registry.yml new file mode 100644 index 0000000000000..f878d5ab86ab6 --- /dev/null +++ b/plugins/package-managers/bazel/src/funTest/assets/projects/synthetic/bazel-expected-output-local-registry.yml @@ -0,0 +1,108 @@ +--- +project: + id: "Bazel::plugins/package-managers/bazel/src/funTest/assets/projects/synthetic/bazel-local-registry/MODULE.bazel:" + definition_file_path: "" + declared_licenses: [] + declared_licenses_processed: {} + vcs: + type: "Git" + url: "" + revision: "" + path: "" + vcs_processed: + type: "Git" + url: "" + revision: "" + path: "" + homepage_url: "" + scopes: + - name: "dev" + dependencies: [] + - name: "main" + dependencies: + - id: "Bazel::glog:0.5.0" + linkage: "STATIC" + dependencies: + - id: "Bazel::gflags:2.2.2" + linkage: "STATIC" + - id: "Bazel::test_module:0.0.1" + linkage: "STATIC" +packages: +- id: "Bazel::gflags:2.2.2" + purl: "pkg:generic/gflags@2.2.2" + declared_licenses: [] + declared_licenses_processed: {} + description: "" + homepage_url: "" + binary_artifact: + url: "" + hash: + value: "" + algorithm: "" + source_artifact: + url: "" + hash: + value: "" + algorithm: "" + vcs: + type: "" + url: "" + revision: "" + path: "" + vcs_processed: + type: "" + url: "" + revision: "" + path: "" +- id: "Bazel::glog:0.5.0" + purl: "pkg:generic/glog@0.5.0" + declared_licenses: [] + declared_licenses_processed: {} + description: "" + homepage_url: "" + binary_artifact: + url: "" + hash: + value: "" + algorithm: "" + source_artifact: + url: "" + hash: + value: "" + algorithm: "" + vcs: + type: "" + url: "" + revision: "" + path: "" + vcs_processed: + type: "" + url: "" + revision: "" + path: "" +- id: "Bazel::test_module:0.0.1" + purl: "pkg:generic/test_module@0.0.1" + declared_licenses: [] + declared_licenses_processed: {} + description: "" + homepage_url: "" + binary_artifact: + url: "" + hash: + value: "" + algorithm: "" + source_artifact: + url: "https://example.com/test_module-0.0.1.zip" + hash: + value: "562c4be7507dc6fb4997ecd648bf935d84efe17b54715fa5cfbddac05279f668" + algorithm: "SHA-256" + vcs: + type: "Git" + url: "" + revision: "" + path: "" + vcs_processed: + type: "Git" + url: "" + revision: "" + path: "" diff --git a/plugins/package-managers/bazel/src/funTest/kotlin/BazelFunTest.kt b/plugins/package-managers/bazel/src/funTest/kotlin/BazelFunTest.kt index 4476d26198665..afdbf505cbf41 100644 --- a/plugins/package-managers/bazel/src/funTest/kotlin/BazelFunTest.kt +++ b/plugins/package-managers/bazel/src/funTest/kotlin/BazelFunTest.kt @@ -37,4 +37,13 @@ class BazelFunTest : StringSpec({ result.toYaml() should matchExpectedResult(expectedResultFile, definitionFile) } + + "Dependencies are detected correctly for a project with a local registries" { + val definitionFile = getAssetFile("projects/synthetic/bazel-local-registry/MODULE.bazel") + val expectedResultFile = getAssetFile("projects/synthetic/bazel-expected-output-local-registry.yml") + + val result = create("Bazel").resolveSingleProject(definitionFile) + + result.toYaml() should matchExpectedResult(expectedResultFile, definitionFile) + } }) diff --git a/plugins/package-managers/bazel/src/test/kotlin/BazelTest.kt b/plugins/package-managers/bazel/src/test/kotlin/BazelTest.kt deleted file mode 100644 index de237945e455f..0000000000000 --- a/plugins/package-managers/bazel/src/test/kotlin/BazelTest.kt +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2024 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.packagemanagers.bazel - -import io.kotest.core.spec.style.WordSpec -import io.kotest.engine.spec.tempdir -import io.kotest.matchers.collections.beEmpty -import io.kotest.matchers.shouldNot - -import org.ossreviewtoolkit.model.config.AnalyzerConfiguration -import org.ossreviewtoolkit.model.config.RepositoryConfiguration -import org.ossreviewtoolkit.utils.test.getAssetFile - -class BazelTest : WordSpec({ - "Bazel package manager" should { - "support local registry" { - val projectAssets = getAssetFile("projects/synthetic/bazel-local-registry/") - val projectDir = tempdir() - projectAssets.copyRecursively(projectDir) - val definitionFile = projectDir.resolve("MODULE.bazel") - - val bazel = Bazel("bazel", projectDir, AnalyzerConfiguration(), RepositoryConfiguration()) - - val resolvedDependencies = bazel.resolveDependencies(definitionFile, emptyMap()) - - resolvedDependencies shouldNot beEmpty() - } - } -})