mirror of
https://github.com/github/codeql.git
synced 2026-04-21 15:05:56 +02:00
Swift: add a test case showing module loading problem
Extractor fails to load separate modules that were built by another version of an actual compiler.
This commit is contained in:
18
swift/integration-tests/partial-modules/A/Package.swift
Normal file
18
swift/integration-tests/partial-modules/A/Package.swift
Normal file
@@ -0,0 +1,18 @@
|
||||
// swift-tools-version: 5.5
|
||||
// The swift-tools-version declares the minimum version of Swift required to build this package.
|
||||
|
||||
import PackageDescription
|
||||
|
||||
let package = Package(
|
||||
name: "A",
|
||||
products: [
|
||||
.library(
|
||||
name: "A",
|
||||
targets: ["A"]),
|
||||
],
|
||||
targets: [
|
||||
.target(
|
||||
name: "A",
|
||||
dependencies: []),
|
||||
]
|
||||
)
|
||||
@@ -0,0 +1,5 @@
|
||||
public struct A {
|
||||
public private(set) var text = Atext
|
||||
|
||||
public init() {}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
let Atext = "Hello, A"
|
||||
18
swift/integration-tests/partial-modules/B/Package.swift
Normal file
18
swift/integration-tests/partial-modules/B/Package.swift
Normal file
@@ -0,0 +1,18 @@
|
||||
// swift-tools-version: 5.5
|
||||
// The swift-tools-version declares the minimum version of Swift required to build this package.
|
||||
|
||||
import PackageDescription
|
||||
|
||||
let package = Package(
|
||||
name: "B",
|
||||
products: [
|
||||
.library(
|
||||
name: "B",
|
||||
targets: ["B"]),
|
||||
],
|
||||
targets: [
|
||||
.target(
|
||||
name: "B",
|
||||
dependencies: []),
|
||||
]
|
||||
)
|
||||
@@ -0,0 +1,5 @@
|
||||
public struct B {
|
||||
public private(set) var text = Btext
|
||||
|
||||
public init() {}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
let Btext = "Hello, B"
|
||||
23
swift/integration-tests/partial-modules/Package.swift
Normal file
23
swift/integration-tests/partial-modules/Package.swift
Normal file
@@ -0,0 +1,23 @@
|
||||
// swift-tools-version: 5.5
|
||||
// The swift-tools-version declares the minimum version of Swift required to build this package.
|
||||
|
||||
import PackageDescription
|
||||
|
||||
let package = Package(
|
||||
name: "partial-modules",
|
||||
products: [
|
||||
.library(
|
||||
name: "partial-modules",
|
||||
targets: ["partial-modules"]),
|
||||
],
|
||||
dependencies: [
|
||||
// Dependencies declare other packages that this package depends on.
|
||||
.package(path: "./A"),
|
||||
.package(path: "./B"),
|
||||
],
|
||||
targets: [
|
||||
.target(
|
||||
name: "partial-modules",
|
||||
dependencies: ["A", "B"]),
|
||||
]
|
||||
)
|
||||
@@ -0,0 +1,11 @@
|
||||
import A
|
||||
import B
|
||||
|
||||
public struct partial_modules {
|
||||
public init() {
|
||||
let a = A()
|
||||
let b = B()
|
||||
print(a.text)
|
||||
print(b.text)
|
||||
}
|
||||
}
|
||||
4
swift/integration-tests/partial-modules/Unknown.ql
Normal file
4
swift/integration-tests/partial-modules/Unknown.ql
Normal file
@@ -0,0 +1,4 @@
|
||||
import swift
|
||||
|
||||
from UnresolvedDotExpr e
|
||||
select e
|
||||
7
swift/integration-tests/partial-modules/test.py
Normal file
7
swift/integration-tests/partial-modules/test.py
Normal file
@@ -0,0 +1,7 @@
|
||||
from create_database_utils import *
|
||||
|
||||
run_codeql_database_create([
|
||||
'env',
|
||||
'swift package clean',
|
||||
'swift build'
|
||||
], lang='swift', keep_trap=True)
|
||||
Reference in New Issue
Block a user