Skip to content

Commit e0e592c

Browse files
committed
Add linux support
1 parent abc3527 commit e0e592c

File tree

7 files changed

+62
-6
lines changed

7 files changed

+62
-6
lines changed

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ let package = Package(
3636
]
3737
),
3838
.testTarget(
39-
name: "ReleaseNotesCoreTests",
39+
name: "ReleaseNotesTests",
4040
dependencies: ["ReleaseNotesCore"]
4141
),
4242
]

Sources/ReleaseNotesCore/App.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import ArgumentParser
22

33

4-
@main
5-
struct App {
6-
static func main() async {
4+
public struct App {
5+
public static func main() async {
76
await ReleaseNotes.main()
87
}
98
}

Sources/ReleaseNotesCore/Parser.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import Parsing
22
import SemanticVersion
3-
import Darwin
43

54

65
enum Parser {
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import Foundation
2+
import ReleaseNotesCore
3+
4+
5+
let group = DispatchGroup()
6+
group.enter()
7+
Task {
8+
defer { group.leave() }
9+
await App.main()
10+
}
11+
12+
group.wait()

Sources/swift-release-notes/release-notes.swift

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import XCTest
2+
import class Foundation.Bundle
3+
4+
5+
final class LaunchTests: XCTestCase {
6+
7+
func test_launch() throws {
8+
let process = Process()
9+
process.executableURL = productsDirectory
10+
.appendingPathComponent("swift-release-notes")
11+
process.arguments = ["--help"]
12+
13+
let pipe = Pipe()
14+
process.standardOutput = pipe
15+
16+
try process.run()
17+
process.waitUntilExit()
18+
19+
let data = pipe.fileHandleForReading.readDataToEndOfFile()
20+
let output = try XCTUnwrap(String(data: data, encoding: .utf8))
21+
22+
XCTAssertEqual(output, """
23+
USAGE: release-notes [<working-direcory>]
24+
25+
ARGUMENTS:
26+
<working-direcory> (default: .)
27+
28+
OPTIONS:
29+
-h, --help Show help information.
30+
31+
32+
""")
33+
}
34+
35+
/// Returns path to the built products directory.
36+
var productsDirectory: URL {
37+
#if os(macOS)
38+
for bundle in Bundle.allBundles where bundle.bundlePath.hasSuffix(".xctest") {
39+
return bundle.bundleURL.deletingLastPathComponent()
40+
}
41+
fatalError("couldn't find the products directory")
42+
#else
43+
return Bundle.main.bundleURL
44+
#endif
45+
}
46+
47+
}

0 commit comments

Comments
 (0)