aboutsummaryrefslogtreecommitdiffstats
path: root/Tests/gameTests/gameTests.swift
diff options
context:
space:
mode:
authorMaksymilian Jopek <maks@jopek.eu>2022-02-15 21:42:58 +0100
committerMaksymilian Jopek <maks@jopek.eu>2022-02-15 21:42:58 +0100
commit445fa02406347e0fc1fb3c8dd778cb706ab4fda8 (patch)
tree7ac301e265ccb12fdb5aa87b348e2183c2dbf2be /Tests/gameTests/gameTests.swift
downloadkappalepeli-445fa02406347e0fc1fb3c8dd778cb706ab4fda8.tar.gz
kappalepeli-445fa02406347e0fc1fb3c8dd778cb706ab4fda8.tar.zst
kappalepeli-445fa02406347e0fc1fb3c8dd778cb706ab4fda8.zip
Iniitial commit - v1.0.0HEADmaster
Diffstat (limited to 'Tests/gameTests/gameTests.swift')
-rw-r--r--Tests/gameTests/gameTests.swift47
1 files changed, 47 insertions, 0 deletions
diff --git a/Tests/gameTests/gameTests.swift b/Tests/gameTests/gameTests.swift
new file mode 100644
index 0000000..b8efa51
--- /dev/null
+++ b/Tests/gameTests/gameTests.swift
@@ -0,0 +1,47 @@
+import XCTest
+import class Foundation.Bundle
+
+final class gameTests: XCTestCase {
+ func testExample() throws {
+ // This is an example of a functional test case.
+ // Use XCTAssert and related functions to verify your tests produce the correct
+ // results.
+
+ // Some of the APIs that we use below are available in macOS 10.13 and above.
+ guard #available(macOS 10.13, *) else {
+ return
+ }
+
+ // Mac Catalyst won't have `Process`, but it is supported for executables.
+ #if !targetEnvironment(macCatalyst)
+
+ let fooBinary = productsDirectory.appendingPathComponent("game")
+
+ let process = Process()
+ process.executableURL = fooBinary
+
+ let pipe = Pipe()
+ process.standardOutput = pipe
+
+ try process.run()
+ process.waitUntilExit()
+
+ let data = pipe.fileHandleForReading.readDataToEndOfFile()
+ let output = String(data: data, encoding: .utf8)
+
+ XCTAssertEqual(output, "Hello, world!\n")
+ #endif
+ }
+
+ /// Returns path to the built products directory.
+ var productsDirectory: URL {
+ #if os(macOS)
+ for bundle in Bundle.allBundles where bundle.bundlePath.hasSuffix(".xctest") {
+ return bundle.bundleURL.deletingLastPathComponent()
+ }
+ fatalError("couldn't find the products directory")
+ #else
+ return Bundle.main.bundleURL
+ #endif
+ }
+}