Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
helje5 committed Jan 8, 2022
2 parents eae73fe + 14439ff commit 4b7f591
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/swift.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- name: Select latest available Xcode
uses: maxim-lobanov/setup-xcode@v1.2.1
with:
xcode-version: 12.2
xcode-version: 13.2.1
- name: Checkout Repository
uses: actions/checkout@v2
- name: Build Swift Debug Package
Expand Down
2 changes: 1 addition & 1 deletion Sources/DocCArchive/Schema_0_1/Document.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ extension DocCArchive.DocCSchema_0_1 {

public var schemaVersion : SchemaVersion
public var identifier : Identifier
public var documentVersion : Int?
public var documentVersion : Int? // was 0, not set in 13.2.1
public var kind : Kind
public var metadata : MetaData
public var hierarchy : Hierarchy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ extension DocCArchive.DocCSchema_0_1 {
}

public var url : String // it's a path, not a URL
public var size : Size
public var size : Size? // size is gone in 13.2.1 as per Issue 5
public var traits : [ Trait ] // TBD: make Set?

func numberOfMatches(against requestedTraits: Set<Trait>) -> Int {
var matchCount = 0
for trait in requestedTraits {
Expand All @@ -39,7 +39,9 @@ extension DocCArchive.DocCSchema_0_1 {
}

public var description: String {
var ms = "<Variant: \(size) traits="
var ms = "<Variant:"
if let size = size { ms += " \(size)" }
ms += " traits="
ms += traits.map({ $0.rawValue }).joined(separator: ",")
ms += " " + url
ms += ">"
Expand Down
49 changes: 26 additions & 23 deletions Tests/DocCArchiveTests/DocumentDecodingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,20 @@ final class DocumentDecodingTests: XCTestCase {
document = try JSONDecoder().decode(DocCArchive.Document.self, from: data)

guard let section = document.primaryContentSections?.first else {
XCTAssert(false, "did not find primary content section"); return
XCTFail("did not find primary content section"); return
}
guard case .content(let contents) = section.kind else {
XCTAssert(false, "did not find content section"); return
XCTFail("did not find content section"); return
}
guard case .aside(style: let style, content: let asideContents) = contents.dropFirst().first else {
XCTAssert(false, "did not find aside"); return
XCTFail("did not find aside"); return
}
XCTAssertEqual(style, .warning, "expected to find warning")
XCTAssert(asideContents.count == 1)
}
catch {
print("ERROR:", error)
XCTAssert(false, "failed to decode: \(error)")
XCTFail("failed to decode: \(error)")
return
}
XCTAssertEqual(document.schemaVersion, .init(major: 0, minor: 1, patch: 0))
Expand All @@ -63,23 +63,23 @@ final class DocumentDecodingTests: XCTestCase {
document = try JSONDecoder().decode(DocCArchive.Document.self, from: data)

guard let section = document.primaryContentSections?.first else {
XCTAssert(false, "did not find primary content section"); return
XCTFail("did not find primary content section"); return
}
guard case .content(let contents) = section.kind else {
XCTAssert(false, "did not find content section"); return
XCTFail("did not find content section"); return
}
guard case .unorderedList(let list) = contents.dropFirst().first else {
XCTAssert(false, "did not find list"); return
XCTFail("did not find list"); return
}
XCTAssertEqual(list.count, 2)
guard case .paragraph(let inlineContent) = list.last?.content.first else {
XCTAssert(false, "did not find paragraph"); return
XCTFail("did not find paragraph"); return
}
XCTAssertEqual(inlineContent.count, 2)
guard case .reference(let id, let isActive, let ot, let otc) =
inlineContent.last else
{
XCTAssert(false, "did not find reference"); return
XCTFail("did not find reference"); return
}
XCTAssertTrue(isActive)
XCTAssertEqual(id, DocCArchive.DocCSchema_0_1.Identifier(
Expand All @@ -89,7 +89,7 @@ final class DocumentDecodingTests: XCTestCase {
}
catch {
print("ERROR:", error)
XCTAssert(false, "failed to decode: \(error)")
XCTFail("failed to decode: \(error)")
return
}
XCTAssertEqual(document.schemaVersion, .init(major: 0, minor: 1, patch: 0))
Expand All @@ -107,7 +107,7 @@ final class DocumentDecodingTests: XCTestCase {
}
catch {
print("ERROR:", error)
XCTAssert(false, "failed to decode: \(error)")
XCTFail("failed to decode: \(error)")
return
}
XCTAssertEqual(document.schemaVersion, .init(major: 0, minor: 1, patch: 0))
Expand All @@ -125,7 +125,7 @@ final class DocumentDecodingTests: XCTestCase {
}
catch {
print("ERROR:", error)
XCTAssert(false, "failed to decode: \(error)")
XCTFail("failed to decode: \(error)")
return
}
XCTAssertEqual(document.schemaVersion, .init(major: 0, minor: 1, patch: 0))
Expand All @@ -143,7 +143,7 @@ final class DocumentDecodingTests: XCTestCase {
}
catch {
print("ERROR:", error)
XCTAssert(false, "failed to decode: \(error)")
XCTFail("failed to decode: \(error)")
return
}
XCTAssertEqual(document.schemaVersion, .init(major: 0, minor: 1, patch: 0))
Expand All @@ -161,7 +161,7 @@ final class DocumentDecodingTests: XCTestCase {
}
catch {
print("ERROR:", error)
XCTAssert(false, "failed to decode: \(error)")
XCTFail("failed to decode: \(error)")
return
}

Expand Down Expand Up @@ -199,7 +199,7 @@ final class DocumentDecodingTests: XCTestCase {
XCTAssertEqual(hero.content.count , 1)
XCTAssertNil (hero.action)
}
else { XCTAssert(false, "Expected hero as the first section") }
else { XCTFail("Expected hero as the first section") }
}
if let section = document.sections.last {
XCTAssertNil (section.title)
Expand Down Expand Up @@ -228,7 +228,7 @@ final class DocumentDecodingTests: XCTestCase {
}
}
}
else { XCTAssert(false, "Expected tasks as the last section") }
else { XCTFail("Expected tasks as the last section") }
}
}

Expand All @@ -241,14 +241,14 @@ final class DocumentDecodingTests: XCTestCase {
"~/Downloads directory")

guard let de = fm.enumerator(atPath: dataDir.path) else {
XCTAssert(false, "did not get dir enum"); return
XCTFail("did not get dir enum"); return
}

var testCount = 0
print("Parse files:")
for p in de {
guard let path = p as? String else {
XCTAssert(false, "expected path"); return
XCTFail("expected path"); return
}
guard !path.contains(".git") else { continue }
guard path.hasSuffix(".json") else { continue }
Expand All @@ -268,13 +268,16 @@ final class DocumentDecodingTests: XCTestCase {
}
catch {
print("ERROR:", error)
XCTAssert(false, "failed to decode: \(error)")
XCTFail("failed to decode: \(error)")
return
}

XCTAssertEqual(document.schemaVersion,
.init(major: 0, minor: 1, patch: 0))
XCTAssertEqual(document.documentVersion, 0)

// was 0, not set in 13.2.1
XCTAssert(document.documentVersion == 0 ||
document.documentVersion == nil)
}

print("# passing tests:", testCount)
Expand All @@ -290,14 +293,14 @@ final class DocumentDecodingTests: XCTestCase {
"~/Downloads directory")

guard let de = fm.enumerator(atPath: dataDir.path) else {
XCTAssert(false, "did not get dir enum"); return
XCTFail("did not get dir enum"); return
}

var testCount = 0
print("Parse files:")
for p in de {
guard let path = p as? String else {
XCTAssert(false, "expected path"); return
XCTFail("expected path"); return
}
guard !path.contains(".git") else { continue }
guard path.hasSuffix(".json") else { continue }
Expand All @@ -317,7 +320,7 @@ final class DocumentDecodingTests: XCTestCase {
}
catch {
print("ERROR:", error)
XCTAssert(false, "failed to decode: \(error)")
XCTFail("failed to decode: \(error)")
return
}

Expand Down

0 comments on commit 4b7f591

Please sign in to comment.