1
0
mirror of https://github.com/nicoverbruggen/phpmon.git synced 2026-03-26 06:00:07 +01:00
Files
app/tests/unit/Conditions/TestURL.swift
Nico Verbruggen 251c53b7bb Conditional tests
- RealWebApiTest requires api.phpmon.test to be reachable or skips
- CommandTest requires php binary or skips
2026-02-16 16:15:41 +01:00

34 lines
739 B
Swift

//
// URLReachable.swift
// PHP Monitor
//
// Created by Nico Verbruggen on 16/02/2026.
// Copyright © 2026 Nico Verbruggen. All rights reserved.
//
import Foundation
class TestURL {
static func isReachable(url: String) -> Bool {
let process = Process()
process.executableURL = URL(fileURLWithPath: "/usr/bin/curl")
process.arguments = [
"-s", "-o", "/dev/null",
"--max-time", "3",
url
]
process.standardOutput = Pipe()
process.standardError = Pipe()
do {
try process.run()
process.waitUntilExit()
return process.terminationStatus == 0
} catch {
return false
}
}
}