1
0
mirror of https://github.com/nicoverbruggen/phpmon.git synced 2026-04-05 18:50:08 +02:00

Conditional tests

- RealWebApiTest requires api.phpmon.test to be reachable or skips
- CommandTest requires php binary or skips
This commit is contained in:
2026-02-16 16:15:41 +01:00
parent 353bf8ffff
commit 251c53b7bb
5 changed files with 80 additions and 3 deletions

View File

@@ -0,0 +1,19 @@
//
// Binaries.swift
// PHP Monitor
//
// Created by Nico Verbruggen on 16/02/2026.
// Copyright © 2026 Nico Verbruggen. All rights reserved.
//
import Foundation
class Binaries {
static func exist(paths: [String]) -> Bool {
for path in paths where FileManager.default.fileExists(atPath: path) {
return true
}
return false
}
}

View File

@@ -0,0 +1,33 @@
//
// 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
}
}
}