Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
stephencelis committed Jul 12, 2024
1 parent 3d4e63e commit db570ca
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions Sources/IssueReporting/IsTesting.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,17 @@
/// }
///
/// To detect if the current task is running inside a test, use ``TestContext/current``, instead.
public let isTesting = ProcessInfo.processInfo.isTesting // TODO: || TestContext.current != nil
public let isTesting = ProcessInfo.processInfo.isTesting

private extension ProcessInfo {
var isTesting: Bool {
if environment.keys.contains("XCTestBundlePath") { return true }
if environment.keys.contains("XCTestConfigurationFilePath") { return true }
if environment.keys.contains("XCTestSessionIdentifier") { return true }
if let argument = arguments.first {
return arguments.contains { argument in
let path = URL(fileURLWithPath: argument)
if path.lastPathComponent == "xctest" { return true }
return path.lastPathComponent == "xctest" || path.pathExtension == "xctest"
}
if let argument = arguments.last {
let path = URL(fileURLWithPath: argument)
if path.pathExtension == "xctest" { return true }
}
return false
}
}
#endif

0 comments on commit db570ca

Please sign in to comment.