bugfixes, better MusicXML support and 1.1.0
This commit is contained in:
@@ -140,7 +140,10 @@ struct ProjectScaffolderTests {
|
||||
|
||||
@Test func workspaceContentsReferencesPackage() {
|
||||
let contents: String = ProjectScaffolder.workspaceContents()
|
||||
#expect(contents.contains("group:Package.swift"))
|
||||
// Must ref the package *directory* (`group:.`), not the Package.swift
|
||||
// file — the file form loads a loose document with no schemes.
|
||||
#expect(contents.contains("group:."))
|
||||
#expect(!contents.contains("group:Package.swift"))
|
||||
#expect(contents.contains("<Workspace"))
|
||||
#expect(contents.hasPrefix("<?xml"))
|
||||
}
|
||||
@@ -170,8 +173,8 @@ struct ProjectScaffolderTests {
|
||||
#expect(contents.contains("group:WS.xcodeproj"),
|
||||
"xcode workspace must ref .xcodeproj for \(template.rawValue)")
|
||||
} else {
|
||||
#expect(contents.contains("group:Package.swift"),
|
||||
"spm workspace must ref Package.swift for \(template.rawValue)")
|
||||
#expect(contents.contains("group:."),
|
||||
"spm workspace must ref the package dir for \(template.rawValue)")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -223,6 +226,9 @@ struct ProjectScaffolderTests {
|
||||
#expect(ProjectTemplate(string: "ui-demo") == .uiDemo)
|
||||
#expect(ProjectTemplate(string: "uidemo") == .uiDemo)
|
||||
#expect(ProjectTemplate(string: "nrt") == .nrt)
|
||||
#expect(ProjectTemplate(string: "score") == .score)
|
||||
#expect(ProjectTemplate(string: "score-musicxml") == .score)
|
||||
#expect(ProjectTemplate(string: "SCORE") == .score)
|
||||
#expect(ProjectTemplate(string: "DEMO") == .demo)
|
||||
#expect(ProjectTemplate(string: "bogus") == nil)
|
||||
#expect(ProjectTemplate(string: "macos-ui-xcode") == .macosUIXcode)
|
||||
@@ -238,6 +244,7 @@ struct ProjectScaffolderTests {
|
||||
#expect(ProjectTemplate.demo.shipsXcodeProject == false)
|
||||
#expect(ProjectTemplate.uiDemo.shipsXcodeProject == false)
|
||||
#expect(ProjectTemplate.nrt.shipsXcodeProject == false)
|
||||
#expect(ProjectTemplate.score.shipsXcodeProject == false)
|
||||
#expect(ProjectTemplate.macosUIXcode.shipsXcodeProject == true)
|
||||
#expect(ProjectTemplate.iosUI.shipsXcodeProject == true)
|
||||
#expect(ProjectTemplate.auv3.shipsXcodeProject == true)
|
||||
@@ -433,6 +440,60 @@ struct ProjectScaffolderTests {
|
||||
#expect(!manifest.contains(".package(name:"))
|
||||
}
|
||||
|
||||
// MARK: - defaultLyrebirdCheckoutPath resolution
|
||||
|
||||
@Test func defaultCheckoutPathNonNilFromSourceTree() throws {
|
||||
// These tests run from inside the Lyrebird source checkout, so the
|
||||
// computed property must resolve to a real root holding Package.swift.
|
||||
let resolved: String = try #require(ProjectScaffolder.defaultLyrebirdCheckoutPath)
|
||||
let manifest: String = (resolved as NSString).appendingPathComponent("Package.swift")
|
||||
#expect(FileManager.default.fileExists(atPath: manifest))
|
||||
}
|
||||
|
||||
@Test func checkoutRootResolvesParentThreeLevelsUp() {
|
||||
let tmp: String = FileManager.default.temporaryDirectory
|
||||
.appendingPathComponent("LyrebirdCheckoutRoot_\(UUID().uuidString)")
|
||||
.path
|
||||
try? FileManager.default.createDirectory(atPath: tmp,
|
||||
withIntermediateDirectories: true,
|
||||
attributes: nil)
|
||||
defer { try? FileManager.default.removeItem(atPath: tmp) }
|
||||
let manifest: String = (tmp as NSString).appendingPathComponent("Package.swift")
|
||||
try? "// swift-tools-version: 6.0\n// Lyrebird".write(toFile: manifest,
|
||||
atomically: true, encoding: .utf8)
|
||||
// Synthetic source path: <tmp>/Sources/LyrebirdCLI/X.swift → up 3 == <tmp>.
|
||||
let synthetic: String = (tmp as NSString)
|
||||
.appendingPathComponent("Sources/LyrebirdCLI/X.swift")
|
||||
#expect(ProjectScaffolder.lyrebirdCheckoutRoot(forSourceFile: synthetic) == tmp)
|
||||
}
|
||||
|
||||
@Test func checkoutRootNilWhenNoManifest() {
|
||||
let tmp: String = FileManager.default.temporaryDirectory
|
||||
.appendingPathComponent("LyrebirdCheckoutNil_\(UUID().uuidString)")
|
||||
.path
|
||||
try? FileManager.default.createDirectory(atPath: tmp,
|
||||
withIntermediateDirectories: true,
|
||||
attributes: nil)
|
||||
defer { try? FileManager.default.removeItem(atPath: tmp) }
|
||||
let synthetic: String = (tmp as NSString).appendingPathComponent("a/b/c.swift")
|
||||
#expect(ProjectScaffolder.lyrebirdCheckoutRoot(forSourceFile: synthetic) == nil)
|
||||
}
|
||||
|
||||
@Test func checkoutRootNilWhenManifestNotLyrebird() {
|
||||
let tmp: String = FileManager.default.temporaryDirectory
|
||||
.appendingPathComponent("LyrebirdCheckoutForeign_\(UUID().uuidString)")
|
||||
.path
|
||||
try? FileManager.default.createDirectory(atPath: tmp,
|
||||
withIntermediateDirectories: true,
|
||||
attributes: nil)
|
||||
defer { try? FileManager.default.removeItem(atPath: tmp) }
|
||||
let manifest: String = (tmp as NSString).appendingPathComponent("Package.swift")
|
||||
try? "// some unrelated SwiftPM package".write(toFile: manifest,
|
||||
atomically: true, encoding: .utf8)
|
||||
let synthetic: String = (tmp as NSString).appendingPathComponent("a/b/c.swift")
|
||||
#expect(ProjectScaffolder.lyrebirdCheckoutRoot(forSourceFile: synthetic) == nil)
|
||||
}
|
||||
|
||||
@Test func macOSAppPBXProjUsesLocalPackageRefWhenPathSet() {
|
||||
let pbx: String = ProjectScaffolder.macOSAppPBXProj(
|
||||
name: "Foo",
|
||||
@@ -606,6 +667,30 @@ struct ProjectScaffolderTests {
|
||||
#expect(!manifest.contains("LyrebirdUI"))
|
||||
}
|
||||
|
||||
// MARK: - score template
|
||||
|
||||
@Test func scoreMainSwiftBuildsAndExportsScore() {
|
||||
let source: String = ProjectScaffolder.mainSwift(name: "MyPiece", template: .score)
|
||||
#expect(source.contains("Score(bpm:"))
|
||||
#expect(source.contains("toMusicXMLString"))
|
||||
#expect(source.contains("fromMusicXML"))
|
||||
#expect(source.contains("score.musicxml"))
|
||||
}
|
||||
|
||||
@Test func scoreMainSwiftRendersOfflineWithNRTDriver() {
|
||||
let source: String = ProjectScaffolder.mainSwift(name: "MyPiece", template: .score)
|
||||
#expect(source.contains("NRTDriver"))
|
||||
#expect(source.contains("score.caf"))
|
||||
#expect(source.contains("engine.schedule"))
|
||||
// Must not embed the Lyrebird copyright in emitted user source.
|
||||
#expect(!source.contains("Joshua Parmenter"))
|
||||
}
|
||||
|
||||
@Test func scorePackageManifestDoesNotIncludeLyrebirdUI() {
|
||||
let manifest: String = ProjectScaffolder.packageManifest(name: "MyPiece", template: .score)
|
||||
#expect(!manifest.contains("LyrebirdUI"))
|
||||
}
|
||||
|
||||
// MARK: - basic template unchanged by default
|
||||
|
||||
@Test func defaultTemplateIsBasic() {
|
||||
|
||||
Reference in New Issue
Block a user