resgen.swift/Tests/ResgenSwiftTests/ResgenSwiftTests.swift
Thibaut Schmitt 1dbf4c643d
Some checks reported warnings
gitea-openium/resgen.swift/pipeline/head This commit is unstable
Fix tests for Jenkins that always build for iOS
2025-04-30 12:03:57 +02:00

49 lines
1.4 KiB
Swift

import XCTest
import class Foundation.Bundle
@testable import ResgenSwift
final class ResgenCLITests: 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
}
// Process available on Mac only
#if os(macOS)
let fooBinary = productsDirectory.appendingPathComponent("ResgenSwift")
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, 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
}
}