Skip to content

Commit 9b7ac6d

Browse files
committed
Eh, just borrow the implementation from TSC
1 parent 7e80638 commit 9b7ac6d

File tree

5 files changed

+206
-169
lines changed

5 files changed

+206
-169
lines changed

Sources/TestingMacros/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,9 @@ target_sources(TestingMacros PRIVATE
9999
Support/AvailabilityGuards.swift
100100
Support/CommentParsing.swift
101101
Support/ConditionArgumentParsing.swift
102-
Support/CRC32.swift
103102
Support/DiagnosticMessage.swift
104103
Support/DiagnosticMessage+Diagnosing.swift
104+
Support/SHA256.swift
105105
Support/SourceCodeCapturing.swift
106106
Support/SourceLocationGeneration.swift
107107
Support/TestContentGeneration.swift

Sources/TestingMacros/ConditionMacro.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -447,17 +447,15 @@ extension ExitTestConditionMacro {
447447
context.diagnose(.captureClauseUnsupported(captureClause, in: closureExpr, inExitTest: macro))
448448
}
449449

450-
var exitTestID: (UInt64, UInt64)
450+
let exitTestID: (UInt64, UInt64)
451451
if let sourceLocation = context.location(of: macro, at: .afterLeadingTrivia, filePathMode: .fileID),
452452
var fileID = sourceLocation.file.as(StringLiteralExprSyntax.self)?.representedLiteralValue,
453453
let line = sourceLocation.line.as(IntegerLiteralExprSyntax.self)?.representedLiteralValue,
454454
let column = sourceLocation.column.as(IntegerLiteralExprSyntax.self)?.representedLiteralValue {
455455
exitTestID.0 = fileID.withUTF8(make64BitHash)
456456
exitTestID.1 = (UInt64(line) << 32) | UInt64(column)
457457
} else {
458-
// TODO: use UUID() here if we can link to Foundation?
459-
exitTestID.0 = .random(in: 0 ... .max)
460-
exitTestID.1 = .random(in: 0 ... .max)
458+
fatalError("Could not determine the source location of this exit test. Please file a bug report at https://github.com/swiftlang/swift-testing/issues/new")
461459
}
462460
let exitTestIDExpr: ExprSyntax = "(\(IntegerLiteralExprSyntax(exitTestID.0, radix: .hex)), \(IntegerLiteralExprSyntax(exitTestID.1, radix: .hex)))"
463461

Sources/TestingMacros/Support/Additions/MacroExpansionContextAdditions.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ extension MacroExpansionContext {
6666
let hashValue = make64BitHash(identifierCharacters.utf8)
6767
let suffix = String(hashValue, radix: 16, uppercase: false)
6868

69-
// If the caller did not specify a prefix and the CRC32 value starts with a
69+
// If the caller did not specify a prefix and the hash value starts with a
7070
// digit, include a single-character prefix to ensure that Swift's name
7171
// demangling still works correctly.
7272
var prefix = prefix

Sources/TestingMacros/Support/CRC32.swift

Lines changed: 0 additions & 163 deletions
This file was deleted.

0 commit comments

Comments
 (0)