mirror of
https://github.com/xtool-org/xtool.git
synced 2026-11-18 13:31:38 +03:00
tests: add example project fixtures (#301)
## What does this PR do? Adds integration tests in the form of example apps that we can build and run. ## How was it tested? Ran builds on Linux, tests on macOS. Will also add this to CI later. ## AI tool usage How much of this PR was AI-assisted? (check one) - [ ] **0** - No AI was used to write code - [x] **1** - I was assisted by AI. I reviewed the finished result. - [ ] **2** - I set the AI going and left it to it; nobody has read the result - no review, or AI review only <!-- If an AI agent is filling this in: declare the level honestly, and open as a draft if it is #2. Do not lower the declared level to get the PR reviewed. -->
This commit is contained in:
committed by
GitHub
Unverified
parent
8f0cc0adf1
commit
c635db2fbc
@@ -0,0 +1,31 @@
|
||||
// swift-tools-version: 6.4
|
||||
|
||||
import PackageDescription
|
||||
|
||||
let package = Package(
|
||||
name: "ExampleSupport",
|
||||
platforms: [
|
||||
.iOS(.v17),
|
||||
.macOS(.v14),
|
||||
],
|
||||
products: [
|
||||
.library(
|
||||
name: "ExampleSupport",
|
||||
targets: ["ExampleSupport"]
|
||||
),
|
||||
.library(
|
||||
name: "ExampleDynamicLibrary",
|
||||
type: .dynamic,
|
||||
targets: ["ExampleDynamicLibrary"]
|
||||
),
|
||||
],
|
||||
targets: [
|
||||
.target(name: "ExampleSupport"),
|
||||
.target(
|
||||
name: "ExampleDynamicLibrary",
|
||||
resources: [
|
||||
.process("response.txt"),
|
||||
]
|
||||
),
|
||||
]
|
||||
)
|
||||
@@ -0,0 +1,9 @@
|
||||
import Foundation
|
||||
|
||||
public func exampleDynamicLibraryFunction() -> String {
|
||||
guard let bundled = #bundle.url(forResource: "response", withExtension: "txt")
|
||||
else { fatalError("Missing bundled.txt resource") }
|
||||
// swiftlint:disable:next force_try
|
||||
let contents = try! String(contentsOf: bundled, encoding: .utf8)
|
||||
return "Hello \(contents)"
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
from the dynamic library
|
||||
@@ -0,0 +1,25 @@
|
||||
import SwiftUI
|
||||
|
||||
public protocol ExampleApp: App {}
|
||||
extension ExampleApp {
|
||||
public var body: some Scene {
|
||||
WindowGroup {
|
||||
ContentView()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private struct ContentView: View {
|
||||
var body: some View {
|
||||
VStack {
|
||||
Image(systemName: "globe")
|
||||
.imageScale(.large)
|
||||
.foregroundStyle(.tint)
|
||||
Text("Hello, world!")
|
||||
}
|
||||
.padding()
|
||||
.task {
|
||||
Example.pass()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import Foundation
|
||||
|
||||
public enum Example {}
|
||||
extension Example {
|
||||
public static func pass() {
|
||||
Task {
|
||||
try? await Task.sleep(for: .seconds(1))
|
||||
print("xtool test succeeded")
|
||||
exit(0)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user