-
Notifications
You must be signed in to change notification settings - Fork 314
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(bazel):
MODULE.bazel
files from a local registry should be ign…
…ored Running the Analyzer on a project depending on packages present in a local registry currently fails with "Unable to create the AnalyzerResult as it contains packages and projects with the same ids". This is because the `MODULE.bazel` files present in the local registry should not be considered as definition files (issue [1]). This commit adds a test for this issue. [1]: #9076 Signed-off-by: Nicolas Nobelis <[email protected]>
- Loading branch information
1 parent
2b2bb87
commit e571858
Showing
11 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
...ckage-managers/bazel/src/funTest/assets/projects/synthetic/bazel-local-registry2/.bazelrc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
common --registry=file://%workspace%/registry/ | ||
|
||
common --registry=https://raw.githubusercontent.com/bazelbuild/bazel-central-registry/main/ | ||
|
1 change: 1 addition & 0 deletions
1
...-managers/bazel/src/funTest/assets/projects/synthetic/bazel-local-registry2/.bazelversion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
7.0.1 |
1 change: 1 addition & 0 deletions
1
...e-managers/bazel/src/funTest/assets/projects/synthetic/bazel-local-registry2/MODULE.bazel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
bazel_dep(name = "module_a", version = "0.0.1") |
3 changes: 3 additions & 0 deletions
3
.../src/funTest/assets/projects/synthetic/bazel-local-registry2/registry/bazel_registry.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"module_base_path": "../modulesSrc/" | ||
} |
6 changes: 6 additions & 0 deletions
6
...ets/projects/synthetic/bazel-local-registry2/registry/modules/module_a/0.0.1/MODULE.bazel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module( | ||
name = "module_a", | ||
version = "0.0.1", | ||
) | ||
|
||
bazel_dep(name = "module_b", version = "0.0.1") |
4 changes: 4 additions & 0 deletions
4
...sets/projects/synthetic/bazel-local-registry2/registry/modules/module_a/0.0.1/source.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"integrity": "sha256-VixL51B9xvtJl+zWSL+TXYTv4XtUcV+lz73awFJ59mg=", | ||
"url": "https://example.com/module_a-0.0.1.zip" | ||
} |
9 changes: 9 additions & 0 deletions
9
...t/assets/projects/synthetic/bazel-local-registry2/registry/modules/module_a/metadata.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"homepage": "", | ||
"maintainers": [], | ||
"repository": [], | ||
"versions": [ | ||
"0.0.1" | ||
], | ||
"yanked_versions": {} | ||
} |
4 changes: 4 additions & 0 deletions
4
...ets/projects/synthetic/bazel-local-registry2/registry/modules/module_b/0.0.1/MODULE.bazel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module( | ||
name = "module_b", | ||
version = "0.0.1", | ||
) |
4 changes: 4 additions & 0 deletions
4
...sets/projects/synthetic/bazel-local-registry2/registry/modules/module_b/0.0.1/source.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"integrity": "sha256-VixL51B9xvtJl+zWSL+TXYTv4XtUcV+lz73awFJ59mg=", | ||
"url": "https://example.com/module_b-0.0.1.zip" | ||
} |
9 changes: 9 additions & 0 deletions
9
...t/assets/projects/synthetic/bazel-local-registry2/registry/modules/module_b/metadata.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"homepage": "", | ||
"maintainers": [], | ||
"repository": [], | ||
"versions": [ | ||
"0.0.1" | ||
], | ||
"yanked_versions": {} | ||
} |
46 changes: 46 additions & 0 deletions
46
plugins/package-managers/bazel/src/funTest/kotlin/BazelDetectionTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright (C) 2024 The ORT Project Authors (see <https://github.com/oss-review-toolkit/ort/blob/main/NOTICE>) | ||
* | ||
* 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.assertions.throwables.shouldThrow | ||
import io.kotest.core.spec.style.StringSpec | ||
import io.kotest.matchers.nulls.shouldNotBeNull | ||
import io.kotest.matchers.string.shouldContain | ||
|
||
import org.ossreviewtoolkit.analyzer.analyze | ||
import org.ossreviewtoolkit.utils.test.getAssetFile | ||
|
||
class BazelDetectionTest : StringSpec({ | ||
"MODULE.bazel files present in a local registry should not be considered as definition files" { | ||
val definitionFile = getAssetFile("projects/synthetic/bazel-local-registry2/MODULE.bazel") | ||
|
||
val exception = shouldThrow<IllegalArgumentException> { | ||
analyze(definitionFile.parentFile, packageManagers = listOf(Bazel.Factory())) | ||
} | ||
|
||
exception.shouldNotBeNull { | ||
// Running the Analyzer on a project depending on packages present in a local registry currently fails | ||
// with this message (issue #9076). This is because the "MODULE.bazel" files present in the local | ||
// registry should not be considered as definition files. | ||
message shouldContain | ||
"Unable to create the AnalyzerResult as it contains packages and projects with the same ids" | ||
} | ||
} | ||
}) |