@@ -47,7 +47,7 @@ private let exampleURLs: [URL] = try! FileManager.default
4747 . map { URL ( fileURLWithPath: $0, relativeTo: examplesDirectory) }
4848 . filter { $0. pathExtension == " shape " }
4949
50- private let shapeScriptVersion : String = {
50+ private let projectVersion : String = {
5151 let string = try ! String ( contentsOf: projectURL)
5252 let start = string. range ( of: " MARKETING_VERSION = " ) !. upperBound
5353 let end = string. range ( of: " ; " , range: start ..< string. endIndex) !. lowerBound
@@ -118,7 +118,7 @@ private let footerLinks: [(String, String)] = [
118118
119119private let versions : [ String ] = {
120120 let fm = FileManager . default
121- var versions = Set ( [ shapeScriptVersion ] )
121+ var versions = Set ( [ projectVersion ] )
122122 let files = try ! fm. contentsOfDirectory ( atPath: helpDirectory. path)
123123 for file in files where file. hasPrefix ( " 1. " ) {
124124 versions. insert ( file)
@@ -158,29 +158,38 @@ private let urlRegex = try! NSRegularExpression(pattern: "\\]\\(([^\\)]*)\\)", o
158158class MetadataTests: XCTestCase {
159159 // MARK: Releases
160160
161- func testLatestVersionInChangelog ( ) {
162- let changelog = try ! String ( contentsOf: changelogURL, encoding: . utf8)
163- XCTAssertTrue ( changelog. contains ( " [ \( shapeScriptVersion ) ] " ) , " CHANGELOG.md does not mention latest release " )
161+ func testProjectVersionMatchesChangelog ( ) throws {
162+ let changelog = try String ( contentsOf: changelogURL, encoding: . utf8)
163+ let range = try XCTUnwrap ( changelog. range ( of : " releases/tag/ " ) )
164164 XCTAssertTrue (
165- changelog. contains ( " (https://github.com/nicklockwood/ShapeScript/releases/tag/ \( shapeScriptVersion) ) " ) ,
165+ changelog [ range. upperBound... ] . hasPrefix ( projectVersion) ,
166+ " Project version \( projectVersion) does not match most recent tag in CHANGELOG.md "
167+ )
168+ }
169+
170+ func testLatestVersionInChangelog( ) throws {
171+ let changelog = try String ( contentsOf: changelogURL, encoding: . utf8)
172+ XCTAssertTrue ( changelog. contains ( " [ \( projectVersion) ] " ) , " CHANGELOG.md does not mention latest release " )
173+ XCTAssertTrue (
174+ changelog. contains ( " (https://github.com/nicklockwood/ShapeScript/releases/tag/ \( projectVersion) ) " ) ,
166175 " CHANGELOG.md does not include correct link for latest release "
167176 )
168177 }
169178
170- func testLatestVersionInPodspec( ) {
171- let podspec = try ! String ( contentsOf: podspecURL, encoding: . utf8)
179+ func testLatestVersionInPodspec( ) throws {
180+ let podspec = try String ( contentsOf: podspecURL, encoding: . utf8)
172181 XCTAssertTrue (
173- podspec. contains ( " \" version \" : \" \( shapeScriptVersion ) \" " ) ,
182+ podspec. contains ( " \" version \" : \" \( projectVersion ) \" " ) ,
174183 " Podspec version does not match latest release "
175184 )
176185 XCTAssertTrue (
177- podspec. contains ( " \" tag \" : \" \( shapeScriptVersion ) \" " ) ,
186+ podspec. contains ( " \" tag \" : \" \( projectVersion ) \" " ) ,
178187 " Podspec tag does not match latest release "
179188 )
180189 }
181190
182191 func testVersionConstantUpdated( ) {
183- XCTAssertEqual ( ShapeScript . version, shapeScriptVersion )
192+ XCTAssertEqual ( ShapeScript . version, projectVersion )
184193 }
185194
186195 func testChangelogDatesAreAscending( ) throws {
@@ -202,7 +211,7 @@ class MetadataTests: XCTestCase {
202211 }
203212
204213 func testUpdateWhatsNew( ) throws {
205- let changelog = try ! String ( contentsOf: changelogURL, encoding: . utf8)
214+ let changelog = try String ( contentsOf: changelogURL, encoding: . utf8)
206215 var releases = [ ( version: String, date: String, notes: [ String] ) ] ( )
207216 var notes = [ String] ( )
208217 for line in changelog. split ( separator: " \n " ) {
@@ -550,9 +559,9 @@ class MetadataTests: XCTestCase {
550559
551560 func testExportVersionedHelp() throws {
552561 let fm = FileManager.default
553- let outputDirectory = helpDirectory.appendingPathComponent(shapeScriptVersion )
562+ let outputDirectory = helpDirectory.appendingPathComponent(projectVersion )
554563 guard fm.fileExists(atPath: outputDirectory.path) else {
555- XCTFail( " Help directory for \( shapeScriptVersion ) not found " )
564+ XCTFail( " Help directory for \( projectVersion ) not found " )
556565 return
557566 }
558567 let attrs = try fm.attributesOfItem(atPath: outputDirectory.path)
0 commit comments