-
Notifications
You must be signed in to change notification settings - Fork 145
Expand file tree
/
Copy pathTaskAdditions.swift
More file actions
27 lines (26 loc) · 994 Bytes
/
TaskAdditions.swift
File metadata and controls
27 lines (26 loc) · 994 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2025 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for Swift project authors
//
/// Make a (decorated) task name from the given undecorated task name.
///
/// - Parameters:
/// - taskName: The undecorated task name to modify.
///
/// - Returns: A copy of `taskName` with a common prefix applied, or `nil` if
/// `taskName` was `nil`.
func decorateTaskName(_ taskName: String?, withAction action: String?) -> String? {
let prefix = "[Swift Testing]"
return taskName.map { taskName in
#if DEBUG
precondition(!taskName.hasPrefix(prefix), reportBugMessage("Applied prefix '\(prefix)' to task name '\(taskName)' twice."))
#endif
let action = action.map { " - \($0)" } ?? ""
return "\(prefix) \(taskName)\(action)"
}
}