Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update generator to swift 6.0 #782

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Run tests
run: swift test
generator-tests:
runs-on: macos-13
runs-on: macos-15
env:
RUNALL: "true"
steps:
Expand All @@ -29,7 +29,7 @@ jobs:
- name: Run tests
run: swift test --package-path ./generator
generator-template-tests:
runs-on: macos-13
runs-on: macos-15
steps:
- name: Checkout code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.3
// swift-tools-version:6.0

import PackageDescription
import Foundation
Expand Down
2 changes: 1 addition & 1 deletion generator/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ let package = Package(
dependencies: [
.package(url: "https://github.com/stencilproject/Stencil.git", from: "0.15.1"),
.package(url: "https://github.com/LebJe/TOMLKit.git", from: "0.5.5"),
.package(url: "https://github.com/apple/swift-format", from: "508.0.1"),
.package(url: "https://github.com/apple/swift-format", from: "600.0.0"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
Expand Down
2 changes: 1 addition & 1 deletion generator/Sources/Generator/generator-help.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class GeneratorHelp {
} catch {
throw GeneratorError.remoteError("No remote file found")
}
let data = try String(contentsOf: url) ?? ""
let data = try String(contentsOf: url, encoding: .utf8)
let fileData = Data(data.utf8)
json = try JSONSerialization.jsonObject(with: fileData, options: []) as? [String: Any] ?? [:]
}
Expand Down
2 changes: 1 addition & 1 deletion generator/Sources/Generator/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class Generator {
var text = ""
let configuration = Configuration()
let swiftFormat = SwiftFormatter(configuration: configuration)
try swiftFormat.format(source: template, assumingFileURL: nil, to: &text)
try swiftFormat.format(source: template, assumingFileURL: nil, selection: .infinite, to: &text)
try text.write(toFile: path, atomically: true, encoding: .utf8)
}

Expand Down
41 changes: 21 additions & 20 deletions generator/Tests/GeneratorTests/GeneratorTests.swift
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
import XCTest
import Testing
@testable import Generator

class GeneratorTests: XCTestCase {
func testAllTestsIncluded() {
let generatorHelp = GeneratorHelp(exercise: "two-fer", filePath: "./Tests/GeneratorTests/files/all-tests-included")
XCTAssertNoThrow(try generatorHelp.toml())
let expected = ["1cf3e15a-a3d7-4a87-aeb3-ba1b43bc8dce", "3549048d-1a6e-4653-9a79-b0bda163e8d5", "b4c6dbb8-b4fb-42c2-bafd-10785abe7709"]
XCTAssertEqual(generatorHelp.uuids, expected)
}
@Test("Testing having all tests be included")
func testAllTestsIncluded() {
let generatorHelp = GeneratorHelp(exercise: "two-fer", filePath: "./Tests/GeneratorTests/files/all-tests-included")
#expect(throws: Never.self) {try generatorHelp.toml()}
let expected = ["1cf3e15a-a3d7-4a87-aeb3-ba1b43bc8dce", "3549048d-1a6e-4653-9a79-b0bda163e8d5", "b4c6dbb8-b4fb-42c2-bafd-10785abe7709"]
#expect(generatorHelp.uuids == expected)
}

func testAllTestsRemoved() {
let generatorHelp = GeneratorHelp(exercise: "two-fer", filePath: "./Tests/GeneratorTests/files/all-test-removed")
XCTAssertNoThrow(try generatorHelp.toml())
let expected: [String] = []
XCTAssertEqual(generatorHelp.uuids, expected)
}
@Test("Testing having all tests be removed")
func testAllTestsRemoved() {
let generatorHelp = GeneratorHelp(exercise: "two-fer", filePath: "./Tests/GeneratorTests/files/all-test-removed")
#expect(throws: Never.self) {try generatorHelp.toml()}
let expected: [String] = []
#expect(generatorHelp.uuids == expected)
}

func testTwoTestsRemoved() {
let generatorHelp = GeneratorHelp(exercise: "two-fer", filePath: "./Tests/GeneratorTests/files/two-tests-removed")
XCTAssertNoThrow(try generatorHelp.toml())
let expected = ["b4c6dbb8-b4fb-42c2-bafd-10785abe7709"]
XCTAssertEqual(generatorHelp.uuids, expected)
}
@Test("Testing having two tests be removed")
func testTwoTestsRemoved() {
let generatorHelp = GeneratorHelp(exercise: "two-fer", filePath: "./Tests/GeneratorTests/files/two-tests-removed")
#expect(throws: Never.self) {try generatorHelp.toml()}
let expected = ["b4c6dbb8-b4fb-42c2-bafd-10785abe7709"]
#expect(generatorHelp.uuids == expected)
}
Loading