From 0ded290ad7592ad96c67965915f4b42aff462952 Mon Sep 17 00:00:00 2001 From: Nate Cook Date: Tue, 7 Feb 2023 09:20:54 -0800 Subject: [PATCH] Reduced test case for strange test crashes This is a very odd bug that is showing up in CI and on the command line, but not in Xcode with a similar toolchain selected. The `GoodBadFunctionTests.swift` file has a reduced test case that demonstrates the problem: With this code included, I see several _other_ tests that crash, even in different test modules. The problem disappears if you comment out the call to `badFunction`, but then re-appears if you make `badFunction` internal instead of fileprivate. I've been testing this with `swift-DEVELOPMENT-SNAPSHOT-2023-01-30-a.xctoolchain`. --- .../GoodBadFunctionTests.swift | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 Tests/RegexBuilderTests/GoodBadFunctionTests.swift diff --git a/Tests/RegexBuilderTests/GoodBadFunctionTests.swift b/Tests/RegexBuilderTests/GoodBadFunctionTests.swift new file mode 100644 index 000000000..33af425fb --- /dev/null +++ b/Tests/RegexBuilderTests/GoodBadFunctionTests.swift @@ -0,0 +1,18 @@ +import XCTest +import _StringProcessing +@testable import RegexBuilder + +func goodFunction(_ r: some RegexComponent) { + _ = try? r.regex.firstMatch(in: "...") +} + +fileprivate func badFunction(_ r: Regex) { + _ = try? r.firstMatch(in: "...") +} + +class GoodBadFunctionTests: XCTestCase { + func testGoodBadFunctions() { + goodFunction(Regex { "asdf" }) + badFunction(Regex { "asdf" }) + } +}