|
| 1 | +// |
| 2 | +// This source file is part of the Swift.org open source project |
| 3 | +// |
| 4 | +// Copyright (c) 2026 Apple Inc. and the Swift project authors |
| 5 | +// Licensed under Apache License v2.0 with Runtime Library Exception |
| 6 | +// |
| 7 | +// See https://swift.org/LICENSE.txt for license information |
| 8 | +// See https://swift.org/CONTRIBUTORS.txt for Swift project authors |
| 9 | +// |
| 10 | + |
| 11 | +/// A standardized message inviting a user to file a bug report at the provided |
| 12 | +/// URL. |
| 13 | +package var fileABugMessage: String { |
| 14 | + _fileABugMessage(context: "") |
| 15 | +} |
| 16 | + |
| 17 | +/// A standardized message inviting a user to file a bug report at the provided |
| 18 | +/// URL and include the specified contextual information. |
| 19 | +/// |
| 20 | +/// - Parameters: |
| 21 | +/// - context: Additional diagnostic information to include with the bug |
| 22 | +/// report message. |
| 23 | +/// |
| 24 | +/// - Returns: A string combining a standard request to file a bug report (with |
| 25 | +/// a URL provided) and `context`. |
| 26 | +package func fileABugMessage(context: String) -> String { |
| 27 | + _fileABugMessage(context: context) |
| 28 | +} |
| 29 | + |
| 30 | +/// Construct a message inviting a user to file a bug report with some optional |
| 31 | +/// context to provide. |
| 32 | +/// |
| 33 | +/// - Parameters: |
| 34 | +/// - context: Optional additional diagnostic information to include with the |
| 35 | +/// bug report message. |
| 36 | +/// |
| 37 | +/// - Returns: A string combining a standard request to file a bug report (with |
| 38 | +/// a URL provided) and `context`, if provided. |
| 39 | +/// |
| 40 | +/// This common implementation function is provided because calling |
| 41 | +/// `fileABugMessage(context:)` directly from the `fileABugMessage` property |
| 42 | +/// getter isn't supported since they have the same base name. |
| 43 | +private func _fileABugMessage(context: String?) -> String { |
| 44 | + var result = "Please file a bug report at https://github.com/swiftlang/swift-testing/issues/new" |
| 45 | + if let context { |
| 46 | + result += " and include this information: \(context)" |
| 47 | + } |
| 48 | + return result |
| 49 | +} |
0 commit comments