Skip to content

Commit

Permalink
test(swiftpm): Test analyzing a definition file without deps
Browse files Browse the repository at this point in the history
This is a test for the bug fixed by 14dc179.

Signed-off-by: Frank Viernau <[email protected]>
  • Loading branch information
fviernau committed Feb 13, 2024
1 parent 0264f7f commit dca2be0
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
project:
id: "SwiftPM::src/funTest/assets/projects/synthetic/project-without-deps/Package.swift:<REPLACE_REVISION>"
definition_file_path: "<REPLACE_DEFINITION_FILE_PATH>"
declared_licenses: []
declared_licenses_processed: {}
vcs:
type: ""
url: ""
revision: ""
path: ""
vcs_processed:
type: "Git"
url: "<REPLACE_URL_PROCESSED>"
revision: "<REPLACE_REVISION>"
path: "<REPLACE_PATH>"
homepage_url: ""
scopes:
- name: "dependencies"
dependencies: []
packages: []
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// swift-tools-version: 5.6
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "MyPackage",
platforms: [
.iOS(.v10)
],
products: [
.library(
name: "MyPackage",
targets: ["MyPackage"]),
],
targets: [
.target(name: "MyPackage")
]
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// The Swift Programming Language
// https://docs.swift.org/swift-book

print("Hello, world!")
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,17 @@ class SwiftPmFunTest : WordSpec({
result.withInvariantIssues().toYaml() should matchExpectedResult(expectedResultFile, definitionFile)
}
}

"Analyzing a definition file without dependencies" should {
"return the correct result" {
// Note: SwiftPM does not create a lockfile if there are no dependencies which is a corner case.
val definitionFile = getAssetFile("projects/synthetic/project-without-deps/Package.swift")
val expectedResultFile = getAssetFile("projects/synthetic/expected-output-project-without-deps.yml")

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

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

0 comments on commit dca2be0

Please sign in to comment.