Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion .github/actions/uitests/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,16 @@ runs:
Example.xcodeproj/xcshareddata/xcschemes/SUI_UITests.xcscheme \
Example.xcodeproj/xcshareddata/xcschemes/OSUI_UITests.xcscheme

- name: Prepare isolated build directory
id: build-directory
shell: bash
run: |
build_root="${RUNNER_TEMP:-/tmp}/uitests-build-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT:-0}-${{ inputs.artifact-name }}"
derived_data_path="$build_root/DerivedData"
rm -rf "$derived_data_path"
mkdir -p "$derived_data_path"
echo "derived-data-path=$derived_data_path" >> "$GITHUB_OUTPUT"

- name: Record baseline images with SwiftUI
id: record-baseline
if: steps.reference.outputs.needs-record == 'true'
Expand Down Expand Up @@ -219,6 +229,7 @@ runs:
-destination "${{ inputs.destination }}" \
-skipMacroValidation \
-skipPackagePluginValidation \
-derivedDataPath "${{ steps.build-directory.outputs.derived-data-path }}" \
2>&1 || record_status=$?

if [[ "$record_status" -ne 0 ]]; then
Expand Down Expand Up @@ -254,7 +265,7 @@ runs:
shell: bash
run: |
cd Example
uitest_tmp="${RUNNER_TEMP:-/tmp}/uitests-${GITHUB_RUN_ID}-${{ inputs.platform }}"
uitest_tmp="${RUNNER_TEMP:-/tmp}/uitests-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT:-0}-${{ inputs.artifact-name }}"
rm -rf "$uitest_tmp"
mkdir -p "$uitest_tmp/artifacts"
result_bundle="$uitest_tmp/${{ inputs.platform }}-uitest.xcresult"
Expand All @@ -271,6 +282,7 @@ runs:
-destination "${{ inputs.destination }}" \
-skipMacroValidation \
-skipPackagePluginValidation \
-derivedDataPath "${{ steps.build-directory.outputs.derived-data-path }}" \
-resultBundlePath "$result_bundle" \
2>&1 | tee "$test_log"

Expand Down Expand Up @@ -311,3 +323,12 @@ runs:
path: ${{ steps.uitest.outputs.xcresult_archive }}
archive: false
retention-days: 7

- name: Clean up isolated build directory
if: always()
shell: bash
run: |
derived_data_path="${{ steps.build-directory.outputs.derived-data-path }}"
if [[ -n "$derived_data_path" ]]; then
rm -rf "$derived_data_path"
fi
21 changes: 21 additions & 0 deletions .github/workflows/compatibility_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,15 @@ jobs:
shell: bash
- name: Install xcbeautify
run: brew install xcbeautify
- name: Prepare isolated DerivedData
shell: bash
run: |
openswiftui_derived_data_path="${RUNNER_TEMP:-/tmp}/compatibility-ios-derived-data-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT:-0}-${{ matrix.ios-version }}-${{ matrix.release }}-openswiftui"
swiftui_derived_data_path="${RUNNER_TEMP:-/tmp}/compatibility-ios-derived-data-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT:-0}-${{ matrix.ios-version }}-${{ matrix.release }}-swiftui"
rm -rf "$openswiftui_derived_data_path" "$swiftui_derived_data_path"
mkdir -p "$openswiftui_derived_data_path" "$swiftui_derived_data_path"
echo "OPENSWIFTUI_DERIVED_DATA_PATH=$openswiftui_derived_data_path" >> "$GITHUB_ENV"
echo "SWIFTUI_DERIVED_DATA_PATH=$swiftui_derived_data_path" >> "$GITHUB_ENV"
- name: Run compatibility tests on OpenSwiftUI + iOS
run: |
set -o pipefail
Expand All @@ -110,6 +119,7 @@ jobs:
-configuration Debug \
-destination "platform=iOS Simulator,OS=${{ matrix.ios-version }},name=${{ matrix.ios-simulator-name }},arch=x86_64" \
-only-testing:OpenSwiftUICompatibilityTests \
-derivedDataPath "$OPENSWIFTUI_DERIVED_DATA_PATH" \
-skipMacroValidation \
-skipPackagePluginValidation \
ONLY_ACTIVE_ARCH=YES \
Expand All @@ -127,9 +137,20 @@ jobs:
-configuration Debug \
-destination "platform=iOS Simulator,OS=${{ matrix.ios-version }},name=${{ matrix.ios-simulator-name }},arch=x86_64" \
-only-testing:OpenSwiftUICompatibilityTests \
-derivedDataPath "$SWIFTUI_DERIVED_DATA_PATH" \
-skipMacroValidation \
-skipPackagePluginValidation \
ONLY_ACTIVE_ARCH=YES \
2>&1 | xcbeautify --renderer github-actions --preserve-unbeautified
env:
OPENSWIFTUI_COMPATIBILITY_TEST: 1
- name: Clean up isolated DerivedData
if: always()
shell: bash
run: |
if [[ -n "${OPENSWIFTUI_DERIVED_DATA_PATH:-}" ]]; then
rm -rf "$OPENSWIFTUI_DERIVED_DATA_PATH"
fi
if [[ -n "${SWIFTUI_DERIVED_DATA_PATH:-}" ]]; then
rm -rf "$SWIFTUI_DERIVED_DATA_PATH"
fi
16 changes: 16 additions & 0 deletions .github/workflows/ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ jobs:
shell: bash
- name: Install xcbeautify
run: brew install xcbeautify
- name: Prepare isolated DerivedData
shell: bash
run: |
derived_data_path="${RUNNER_TEMP:-/tmp}/ios-derived-data-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT:-0}-${{ matrix.ios-version }}-${{ matrix.release }}"
rm -rf "$derived_data_path"
mkdir -p "$derived_data_path"
echo "DERIVED_DATA_PATH=$derived_data_path" >> "$GITHUB_ENV"
- name: Build test target in debug mode
run: |
set -o pipefail
Expand All @@ -55,6 +62,7 @@ jobs:
-scheme OpenSwiftUI \
-configuration Debug \
-destination "platform=iOS Simulator,OS=${{ matrix.ios-version }},name=${{ matrix.ios-simulator-name }},arch=x86_64" \
-derivedDataPath "$DERIVED_DATA_PATH" \
-skipMacroValidation \
-skipPackagePluginValidation \
ONLY_ACTIVE_ARCH=YES \
Expand All @@ -68,7 +76,15 @@ jobs:
-scheme OpenSwiftUI \
-configuration Debug \
-destination "platform=iOS Simulator,OS=${{ matrix.ios-version }},name=${{ matrix.ios-simulator-name }},arch=x86_64" \
-derivedDataPath "$DERIVED_DATA_PATH" \
-skipMacroValidation \
-skipPackagePluginValidation \
ONLY_ACTIVE_ARCH=YES \
2>&1 | xcbeautify --renderer github-actions --preserve-unbeautified
- name: Clean up isolated DerivedData
if: always()
shell: bash
run: |
if [[ -n "${DERIVED_DATA_PATH:-}" ]]; then
rm -rf "$DERIVED_DATA_PATH"
fi
4 changes: 2 additions & 2 deletions Example/Example_Legacy.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1375,10 +1375,10 @@
/* Begin XCRemoteSwiftPackageReference section */
275752022DEE147E003E467C /* XCRemoteSwiftPackageReference "swift-snapshot-testing" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/OpenSwiftUIProject/swift-snapshot-testing";
repositoryURL = "https://github.com/OpenSwiftUIProject/swift-snapshot-testing.git";
requirement = {
kind = exactVersion;
version = "1.18.9-osui";
version = "1.19.2";
};
};
278EF52B2E2272F2009C32EB /* XCRemoteSwiftPackageReference "equatable" */ = {
Expand Down
4 changes: 2 additions & 2 deletions Example/OpenSwiftUIUITests/Export.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import SnapshotTesting

#if OPENSWIFTUI
@_exported import OpenSwiftUI
let shouldRecord: Bool? = nil
let shouldRecord: SnapshotTestingConfiguration.Record? = nil
#else
@_exported import SwiftUI
let shouldRecord: Bool? = true
let shouldRecord: SnapshotTestingConfiguration.Record? = .all

public struct ViewRendererVendor: RawRepresentable, Hashable, CaseIterable {
public let rawValue: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func openSwiftUIAssertSnapshot<V: View>(
perceptualPrecision: Float = 1,
size: CGSize = defaultSize,
named name: String? = nil,
record recording: Bool? = shouldRecord,
record recording: SnapshotTestingConfiguration.Record? = shouldRecord,
timeout: TimeInterval = 5,
fileID: StaticString = #fileID,
file filePath: StaticString = #filePath,
Expand All @@ -93,7 +93,7 @@ func openSwiftUIAssertSnapshot<V: View>(
of value: @autoclosure () -> V,
as snapshotting: Snapshotting<PlatformViewController, PlatformImage>,
named name: String? = nil,
record recording: Bool? = shouldRecord,
record recording: SnapshotTestingConfiguration.Record? = shouldRecord,
timeout: TimeInterval = 5,
fileID: StaticString = #fileID,
file filePath: StaticString = #filePath,
Expand All @@ -119,7 +119,7 @@ func openSwiftUIAssertSnapshot<V: View, Format>(
of value: @autoclosure () -> V,
as snapshotting: Snapshotting<PlatformViewController, Format>,
named name: String? = nil,
record recording: Bool? = shouldRecord,
record recording: SnapshotTestingConfiguration.Record? = shouldRecord,
timeout: TimeInterval = 5,
fileID: StaticString = #fileID,
file filePath: StaticString = #filePath,
Expand All @@ -146,7 +146,7 @@ func openSwiftUIControllerAssertSnapshot<V: PlatformViewController, Format>(
of value: @autoclosure () -> V,
as snapshotting: Snapshotting<PlatformViewController, Format>,
named name: String? = nil,
record recording: Bool? = shouldRecord,
record recording: SnapshotTestingConfiguration.Record? = shouldRecord,
timeout: TimeInterval = 5,
fileID: StaticString = #fileID,
file filePath: StaticString = #filePath,
Expand All @@ -173,7 +173,7 @@ private func openSwiftUIAssertSnapshot<Value, Format>(
of value: @autoclosure () -> Value,
as snapshotting: Snapshotting<Value, Format>,
named name: String? = nil,
record recording: Bool? = shouldRecord,
record recording: SnapshotTestingConfiguration.Record? = shouldRecord,
timeout: TimeInterval = 5,
fileID: StaticString = #fileID,
file filePath: StaticString = #filePath,
Expand Down Expand Up @@ -214,7 +214,7 @@ func openSwiftUIAssertAnimationSnapshot<V: AnimationTestView>(
precision: Float = 1,
perceptualPrecision: Float = 1,
size: CGSize = defaultSize,
record recording: Bool? = shouldRecord,
record recording: SnapshotTestingConfiguration.Record? = shouldRecord,
timeout: TimeInterval = 5,
fileID: StaticString = #fileID,
file filePath: StaticString = #filePath,
Expand Down
8 changes: 4 additions & 4 deletions Example/Tuist/Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Example/Tuist/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ var dependencies: [PackageDescription.Package.Dependency] = [
.package(url: "https://github.com/swiftlang/swift-syntax.git", from: "601.0.0"),
.package(url: "https://github.com/OpenSwiftUIProject/equatable.git", branch: "main"),
.package(url: "https://github.com/OpenSwiftUIProject/SymbolLocator.git", from: "0.2.0"),
.package(url: "https://github.com/OpenSwiftUIProject/swift-snapshot-testing", exact: "1.18.9-osui"),
.package(url: "https://github.com/OpenSwiftUIProject/swift-snapshot-testing.git", exact: "1.19.2"),
]

if enableLookInsideServer {
Expand Down
4 changes: 4 additions & 0 deletions Sources/OpenSwiftUI/App/App/App.swift
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,14 @@ public protocol App {
init()

/* OpenSwiftUI Addition Begin */
#if !OPENSWIFTUI_SWIFTUI_RENDERER
/// The global default renderer configuration used by the app lifecycle.
///
/// If set, OpenSwiftUI applies this configuration to renderers that it
/// creates for the app.
@_spi(StdoutRenderer)
nonisolated static var rendererConfiguration: _RendererConfiguration? { get }
#endif
/* OpenSwiftUI Addition End */
}

Expand All @@ -151,10 +153,12 @@ extension App {
public static func main() {
let app = Self()
/* OpenSwiftUI Addition Begin */
#if !OPENSWIFTUI_SWIFTUI_RENDERER
if let rendererConfiguration = Self.rendererConfiguration,
case let .stdout(options) = rendererConfiguration.renderer {
runStdoutApp(app, options: options)
}
#endif
/* OpenSwiftUI Addition End */
runApp(app)
}
Expand Down
2 changes: 2 additions & 0 deletions Sources/OpenSwiftUI/App/App/Stdout/StdoutApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// StdoutApp.swift
// OpenSwiftUI

#if !OPENSWIFTUI_SWIFTUI_RENDERER
#if canImport(Darwin)
import Darwin
#elseif canImport(Glibc)
Expand Down Expand Up @@ -45,3 +46,4 @@ func runStdoutApp(
}
exit(0)
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ extension DisplayList {
case updating
case rasterizing
/* OpenSwiftUI Addition Begin */
#if !OPENSWIFTUI_SWIFTUI_RENDERER
case stdout
#endif
/* OpenSwiftUI Addition End */
}

Expand All @@ -98,7 +100,9 @@ extension DisplayList {
case .default: state == .updating
case .rasterized: state == .rasterizing
/* OpenSwiftUI Addition Begin */
#if !OPENSWIFTUI_SWIFTUI_RENDERER
case .stdout: state == .stdout
#endif
/* OpenSwiftUI Addition End */
}
if !isValid {
Expand All @@ -117,10 +121,12 @@ extension DisplayList {
rasterizer.renderer.platformViewMode = options.drawsPlatformViews ? .rendered(update: true) : .unsupported
rasterizer.host = host
/* OpenSwiftUI Addition Begin */
#if !OPENSWIFTUI_SWIFTUI_RENDERER
case let .stdout(options):
let stdoutRenderer = renderer as! StdoutDisplayListRenderer
stdoutRenderer.options = options
stdoutRenderer.host = host
#endif
/* OpenSwiftUI Addition End */
}
} else {
Expand All @@ -139,13 +145,15 @@ extension DisplayList {
renderer = rasterizer
state = .rasterizing
/* OpenSwiftUI Addition Begin */
#if !OPENSWIFTUI_SWIFTUI_RENDERER
case let .stdout(options):
renderer = StdoutDisplayListRenderer(
platform: platform,
host: host,
options: options
)
state = .stdout
#endif
/* OpenSwiftUI Addition End */
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// StdoutRendererHost.swift
// OpenSwiftUICore

#if !OPENSWIFTUI_SWIFTUI_RENDERER
import Foundation

// MARK: - StdoutRendererHost
Expand Down Expand Up @@ -103,3 +104,4 @@ final package class StdoutRendererHost<Content>: ViewRendererHost, ViewGraphRend
}

private final class StdoutPlatformViewDefinition: PlatformViewDefinition, @unchecked Sendable {}
#endif
4 changes: 4 additions & 0 deletions Sources/OpenSwiftUICore/Render/RendererConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ public struct _RendererConfiguration {
indirect case rasterized(_ options: _RendererConfiguration.RasterizationOptions = .init())

/* OpenSwiftUI Addition Begin */
#if !OPENSWIFTUI_SWIFTUI_RENDERER
/// A renderer that writes a textual representation of the display list
/// to standard output.
@_spi(StdoutRenderer)
indirect case stdout(_ options: _RendererConfiguration.StdoutOptions = .init())
#endif
/* OpenSwiftUI Addition End */
}

Expand All @@ -51,11 +53,13 @@ public struct _RendererConfiguration {

/* OpenSwiftUI Addition Begin */

#if !OPENSWIFTUI_SWIFTUI_RENDERER
/// Returns a configuration to render the display list to standard output.
@_spi(StdoutRenderer)
public static func stdout(_ options: _RendererConfiguration.StdoutOptions = .init()) -> _RendererConfiguration {
_RendererConfiguration(renderer: .stdout(options))
}
#endif

/* OpenSwiftUI Addition End */

Expand Down
Loading