// // Copyright Amazon.com Inc. or its affiliates. // All Rights Reserved. // // SPDX-License-Identifier: Apache-2.0 // import XCTest import class Foundation.Bundle final class AmplifyXcodeTests: XCTestCase { func testExecutable() throws { guard #available(macOS 10.13, *) else { return } let binary = productsDirectory.appendingPathComponent("amplify-xcode") let process = Process() process.executableURL = binary let pipe = Pipe() process.standardOutput = pipe let errorPipe = Pipe() process.standardError = errorPipe try process.run() process.waitUntilExit() let data = errorPipe.fileHandleForReading.readDataToEndOfFile() let output = String(data: data, encoding: .utf8) XCTAssertTrue(output?.isEmpty == true) } /// 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 } static var allTests = [ ("smokeTest", testExecutable) ] }