import CoreGraphics import Foundation import ParcelCore import Testing @testable import ParcelTestSupport @Suite @MainActor struct MediaCaptureScriptTests { @Test func helpDoesNotBuildLaunchOrCapture() async throws { let directory = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) try FileManager.default.createDirectory(at: directory, withIntermediateDirectories: false) defer { do { try FileManager.default.removeItem(at: directory) } catch { Issue.record(error) } } let script = repositoryRoot().appendingPathComponent("Scripts/capture-media.sh") let result = try await runProcess( executable: URL(fileURLWithPath: "/bin/bash"), arguments: [script.path, "--help"], directory: directory, environment: ["PATH": "/usr/bin:/bin"]) #expect(result.status == 0) #expect(result.errors.isEmpty) let help = String(decoding: result.output, as: UTF8.self) #expect(help.contains("--record")) #expect(help.contains("Screen Recording")) #expect(help.contains("never overwritten")) } @Test(arguments: [[], ["--unknown"], ["--record", "extra"]]) func requiresExplicitRecordingOptIn(arguments: [String]) async throws { let directory = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) try FileManager.default.createDirectory(at: directory, withIntermediateDirectories: false) defer { do { try FileManager.default.removeItem(at: directory) } catch { Issue.record(error) } } let script = repositoryRoot().appendingPathComponent("Scripts/capture-media.sh") let result = try await runProcess( executable: URL(fileURLWithPath: "/bin/bash"), arguments: [script.path] + arguments, directory: directory, environment: ["PATH": "/usr/bin:/bin"]) #expect(result.status == 2) #expect(result.errors.contains("Usage:")) } }