Skip to content

Commit

Permalink
test(swiftpm): Clarify the functional tests a bit
Browse files Browse the repository at this point in the history
Rename the test projects so that it becomes clear that the following
cases are tests:

1. A project / definition file with a lockfile
2. A project / definition file without a lockfile
3. A lockfile only (without a definition file)

While at it, improve the wording in test case names and include the file
format version in one test, to prepare for adding support for further
file format versions.

Signed-off-by: Frank Viernau <frank_viernau@epam.com>
  • Loading branch information
fviernau committed Jan 23, 2024
1 parent a0ea682 commit 56d1226
Show file tree
Hide file tree
Showing 28 changed files with 19 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
project:
id: "SwiftPM::src/funTest/assets/projects/synthetic/spm-app/Package.resolved:<REPLACE_REVISION>"
id: "SwiftPM::src/funTest/assets/projects/synthetic/lockfile-v1/Package.resolved:<REPLACE_REVISION>"
definition_file_path: "<REPLACE_DEFINITION_FILE_PATH>"
declared_licenses: []
declared_licenses_processed: {}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
project:
id: "SwiftPM::src/funTest/assets/projects/synthetic/spm-lib-no-lockfile/Package.swift:"
definition_file_path: "plugins/package-managers/swiftpm/src/funTest/assets/projects/synthetic/spm-lib-no-lockfile/Package.swift"
id: "SwiftPM::src/funTest/assets/projects/synthetic/project-without-lockfile/Package.swift:"
definition_file_path: "plugins/package-managers/swiftpm/src/funTest/assets/projects/synthetic/project-without-lockfile/Package.swift"
declared_licenses: []
declared_licenses_processed: {}
vcs:
Expand All @@ -20,8 +20,8 @@ packages: []
issues:
- timestamp: "1970-01-01T00:00:00Z"
source: "SwiftPM"
message: "SwiftPM failed to resolve dependencies for path 'src/funTest/assets/projects/synthetic/spm-lib-no-lockfile/Package.swift':\
\ IllegalArgumentException: No lockfile found in 'src/funTest/assets/projects/synthetic/spm-lib-no-lockfile'.\
message: "SwiftPM failed to resolve dependencies for path 'src/funTest/assets/projects/synthetic/project-without-lockfile/Package.swift':\
\ IllegalArgumentException: No lockfile found in 'src/funTest/assets/projects/synthetic/project-without-lockfile'.\
\ This potentially results in unstable versions of dependencies. To support this,\
\ enable the 'allowDynamicVersions' option in 'config.yml'."
severity: "ERROR"
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
project:
id: "SwiftPM::src/funTest/assets/projects/synthetic/spm-lib/Package.swift:<REPLACE_REVISION>"
id: "SwiftPM::src/funTest/assets/projects/synthetic/project-with-lockfile/Package.swift:<REPLACE_REVISION>"
definition_file_path: "<REPLACE_DEFINITION_FILE_PATH>"
declared_licenses: []
declared_licenses_processed: {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,30 +31,34 @@ import org.ossreviewtoolkit.utils.test.getAssetFile
import org.ossreviewtoolkit.utils.test.matchExpectedResult

class SwiftPmFunTest : WordSpec({
"Parsing 'Package.resolved' dependencies" should {
"Analyzing a lockfile with file format version 1" should {
"return the correct result" {
val definitionFile = getAssetFile("projects/synthetic/spm-app/Package.resolved")
val expectedResultFile = getAssetFile("projects/synthetic/spm-expected-output-app.yml")
val definitionFile = getAssetFile("projects/synthetic/lockfile-v1/Package.resolved")
val expectedResultFile = getAssetFile("projects/synthetic/expected-output-lockfile-v1.yml")

val result = create(PROJECT_TYPE).resolveSingleProject(definitionFile)

result.toYaml() should matchExpectedResult(expectedResultFile, definitionFile)
}
}

"Parsing 'Package.swift' dependencies" should {
"Analyzing a definition file with a sibling lockfile" should {
"return the correct result" {
val definitionFile = getAssetFile("projects/synthetic/spm-lib/Package.swift")
val expectedResultFile = getAssetFile("projects/synthetic/spm-expected-output-lib.yml")
val definitionFile = getAssetFile("projects/synthetic/project-with-lockfile/Package.swift")
val expectedResultFile = getAssetFile("projects/synthetic/expected-output-project.yml")

val result = create(PROJECT_TYPE).resolveSingleProject(definitionFile, resolveScopes = true)

result.toYaml() should matchExpectedResult(expectedResultFile, definitionFile)
}
}

"show an error if 'allowDynamicVersions' is disabled" {
val definitionFile = getAssetFile("projects/synthetic/spm-lib-no-lockfile/Package.swift")
val expectedResultFile = getAssetFile("projects/synthetic/spm-expected-output-lib-no-lockfile.yml")
"Analyzing a definition file without a lockfile" should {
"return an issue if 'allowDynamicVersions' is disabled" {
val definitionFile = getAssetFile("projects/synthetic/project-without-lockfile/Package.swift")
val expectedResultFile = getAssetFile(
"projects/synthetic/expected-output-project-without-lockfile.yml"
)

val result = create(PROJECT_TYPE, AnalyzerConfiguration(allowDynamicVersions = false))
.resolveSingleProject(definitionFile, resolveScopes = true)
Expand Down

0 comments on commit 56d1226

Please sign in to comment.