Skip to content

Commit c4807e9

Browse files
committed
Tweak tests
1 parent 4a6e702 commit c4807e9

File tree

2 files changed

+30
-52
lines changed

2 files changed

+30
-52
lines changed

Sources/ReleaseNotesCore/ReleaseNotes.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ struct ReleaseNotes: AsyncParsableCommand {
4040
updates = try Parser.packageUpdate.parse(output)
4141
} catch {
4242
print("Failed to parse results from package update.\n")
43-
print("Please file an issue with the the output above.")
43+
print("Please file an issue with the the error output.")
4444
throw error
4545
}
4646

Tests/ReleaseNotesTests/ParserCoreTests.swift

Lines changed: 29 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -20,34 +20,22 @@ import Parsing
2020
final class ParserCoreTests: XCTestCase {
2121

2222
func test_progressLine() throws {
23-
do {
24-
var input = "Updating https://github.com/pointfreeco/swift-parsing\n"[...]
25-
try Parser.progressLine.parse(&input)
26-
}
27-
do {
28-
var input = "Updated https://github.com/apple/swift-argument-parser (0.81s)\n"[...]
29-
try Parser.progressLine.parse(&input)
30-
}
31-
do {
32-
var input = "Computing version for https://github.com/pointfreeco/swift-parsing\n"[...]
33-
try Parser.progressLine.parse(&input)
34-
}
35-
do {
36-
var input = "Computed https://github.com/pointfreeco/swift-parsing at 0.4.1 (0.02s)\n"[...]
37-
try Parser.progressLine.parse(&input)
38-
}
39-
do {
40-
var input = "Creating working copy for https://github.com/JohnSundell/Plot.git\n"[...]
41-
try Parser.progressLine.parse(&input)
42-
}
43-
do {
44-
var input = "Working copy of https://github.com/JohnSundell/Plot.git resolved at 0.10.0\n"[...]
45-
try Parser.progressLine.parse(&input)
46-
}
23+
try Parser.progressLine.parse(
24+
"Updating https://github.com/pointfreeco/swift-parsing\n")
25+
try Parser.progressLine.parse(
26+
"Updated https://github.com/apple/swift-argument-parser (0.81s)\n")
27+
try Parser.progressLine.parse(
28+
"Computing version for https://github.com/pointfreeco/swift-parsing\n")
29+
try Parser.progressLine.parse(
30+
"Computed https://github.com/pointfreeco/swift-parsing at 0.4.1 (0.02s)\n")
31+
try Parser.progressLine.parse(
32+
"Creating working copy for https://github.com/JohnSundell/Plot.git\n")
33+
try Parser.progressLine.parse(
34+
"Working copy of https://github.com/JohnSundell/Plot.git resolved at 0.10.0\n")
4735
}
4836

4937
func test_anyProgress() throws {
50-
var input = """
38+
let input = """
5139
Updating https://github.com/pointfreeco/swift-parsing
5240
Updating https://github.com/apple/swift-argument-parser
5341
Updating https://github.com/SwiftPackageIndex/SemanticVersion
@@ -63,54 +51,44 @@ final class ParserCoreTests: XCTestCase {
6351
Creating working copy for https://github.com/JohnSundell/Plot.git
6452
Working copy of https://github.com/JohnSundell/Plot.git resolved at 0.10.0
6553
66-
"""[...]
67-
try Skip { Parser.progress }.parse(&input)
54+
"""
55+
try Skip { Parser.progress }.parse(input)
6856
}
6957

7058
func test_dependencyCount() throws {
71-
do {
72-
var input = "1 dependency has changed:"[...]
73-
XCTAssertEqual(try Parser.dependencyCount.parse(&input), 1)
74-
}
75-
do {
76-
var input = "12 dependencies have changed:"[...]
77-
XCTAssertEqual(try Parser.dependencyCount.parse(&input), 12)
78-
}
79-
do {
80-
var input = "0 dependencies have changed."[...]
81-
XCTAssertEqual(try Parser.dependencyCount.parse(&input), 0)
82-
}
59+
XCTAssertEqual(try Parser.dependencyCount.parse("1 dependency has changed:"), 1)
60+
XCTAssertEqual(try Parser.dependencyCount.parse("12 dependencies have changed:"), 12)
61+
XCTAssertEqual(try Parser.dependencyCount.parse("0 dependencies have changed."), 0)
8362
}
8463

8564
func test_upToStart() throws {
8665
do {
66+
// Ensure updated revisions are recognised and _not_ consumed
8767
var input = "~ foo"[...]
88-
XCTAssertNotNil(try? Parser.upToStart.parse(&input))
68+
XCTAssertNoThrow(try Parser.upToStart.parse(&input))
8969
XCTAssertEqual(input, "~ foo")
9070
}
9171
do {
72+
// Ensure new packages are recognised and _not_ consumed
9273
var input = "+ foo"[...]
93-
XCTAssertNotNil(try? Parser.upToStart.parse(&input))
74+
XCTAssertNoThrow(try Parser.upToStart.parse(&input))
9475
XCTAssertEqual(input, "+ foo")
9576
}
9677
do {
97-
XCTAssertNotNil(try Parser.upToStart.parse("other"))
78+
// Ensure other output is recognised and consumed
79+
var input = "other"[...]
80+
XCTAssertNoThrow(try Parser.upToStart.parse(&input))
81+
XCTAssertEqual(input, "")
9882
}
9983
}
10084

10185
func test_semanticVersion() throws {
102-
do {
103-
XCTAssertEqual(try Parser.semanticVersion.parse("1.2.3"), .tag(.init(1, 2, 3)))
104-
}
105-
do {
106-
XCTAssertEqual(try? Parser.semanticVersion.parse("1.2.3-b1"), .tag(.init("1.2.3-b1")!))
107-
}
86+
XCTAssertEqual(try Parser.semanticVersion.parse("1.2.3"), .tag(.init(1, 2, 3)))
87+
XCTAssertEqual(try Parser.semanticVersion.parse("1.2.3-b1"), .tag(.init("1.2.3-b1")!))
10888
}
10989

11090
func test_revision() throws {
111-
do {
112-
XCTAssertEqual(try Parser.revision.parse("main"), .branch("main"))
113-
}
91+
XCTAssertEqual(try Parser.revision.parse("main"), .branch("main"))
11492
}
11593

11694
func test_newPackage() throws {

0 commit comments

Comments
 (0)