Skip to content

Commit f18ed27

Browse files
authored
[lldb] Re-enable TestSwiftRegex (#6798)
To evaluate the command `expr -O -- regex`, the target triple needs to specify macOS 13 or greater. The underlying issue should have been an error when `main.swift` was being compiled, but `-disable-availability-checking` was being used. As it was, the expression evaluation would result in this error (which was only seen in the logs): > error: 'Regex' is only available in macOS 13.0 or newer While debugging the issue, the use of `v`/`vo`/`expr`/`expr -O` were split out into separate test functions. Interestingly `vo` will succeed even in the case where `expr -O` did not. This reverts commit de23e76. rdar://106107613
1 parent c144a7e commit f18ed27

File tree

2 files changed

+43
-9
lines changed

2 files changed

+43
-9
lines changed
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
SWIFT_SOURCES := main.swift
2-
SWIFTFLAGS_EXTRAS := -Xfrontend -enable-bare-slash-regex -Xfrontend -disable-availability-checking
1+
ifeq "$(OS)" "Darwin"
2+
OS_SWIFTFLAGS := -target $(ARCH)-apple-macosx13.0
3+
endif
34

5+
SWIFT_SOURCES := main.swift
6+
SWIFTFLAGS_EXTRAS := -enable-bare-slash-regex $(OS_SWIFTFLAGS)
47

58
include Makefile.rules

lldb/test/API/lang/swift/regex/TestSwiftRegex.py

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,54 @@ def setUp(self):
2626
self.main_source = "main.swift"
2727
self.main_source_spec = lldb.SBFileSpec(self.main_source)
2828

29-
@skipIf(bugnumber="rdar://106107613")
3029
@swiftTest
31-
def test_swift_regex(self):
32-
"""Test Swift's regex support"""
30+
@skipIf(macos_version=["<", "13"])
31+
def test_swift_regex_frame_var(self):
32+
"""Test frame variable support for Swift regexes."""
3333
self.build()
3434
lldbutil.run_to_source_breakpoint(
3535
self, 'Set breakpoint here', self.main_source_spec)
3636
self.expect('v regex',
3737
substrs=['_StringProcessing.Regex<(Substring, Substring, Substring, Substring)>) regex = {'])
38-
self.expect('po regex',
39-
substrs=['Regex<(Substring, Substring, Substring, Substring)>'])
40-
4138
self.expect('v dslRegex',
4239
substrs=['(_StringProcessing.Regex<Substring>) dslRegex = {'])
43-
self.expect('po dslRegex',
40+
41+
@swiftTest
42+
@skipIf(macos_version=["<", "13"])
43+
def test_swift_regex_expr_desc(self):
44+
"""Test expression object description support for Swift regexes."""
45+
self.build()
46+
lldbutil.run_to_source_breakpoint(
47+
self, 'Set breakpoint here', self.main_source_spec)
48+
self.expect('expr -O -- regex',
49+
substrs=['Regex<(Substring, Substring, Substring, Substring)>'])
50+
self.expect('expr -O -- dslRegex',
4451
substrs=['Regex<Substring>'])
4552

53+
@swiftTest
54+
@skipIf(macos_version=["<", "13"])
55+
def test_swift_regex_frame_var_desc(self):
56+
"""Test frame variable object description support for Swift regexes."""
57+
self.build()
58+
lldbutil.run_to_source_breakpoint(
59+
self, 'Set breakpoint here', self.main_source_spec)
60+
self.expect('vo regex',
61+
substrs=['Regex<(Substring, Substring, Substring, Substring)>'])
62+
self.expect('vo dslRegex',
63+
substrs=['Regex<Substring>'])
64+
65+
@swiftTest
66+
@skipIf(macos_version=["<", "13"])
67+
def test_swift_regex_expr(self):
68+
"""Test expression support for Swift regexes."""
69+
self.build()
70+
lldbutil.run_to_source_breakpoint(
71+
self, 'Set breakpoint here', self.main_source_spec)
72+
self.expect('expr regex',
73+
substrs=['_StringProcessing.Regex<(Substring, Substring, Substring, Substring)>) $R0 = {'])
74+
self.expect('expr dslRegex',
75+
substrs=['(_StringProcessing.Regex<Substring>) $R1 = {'])
76+
4677
@swiftTest
4778
@skipIf(macos_version=["<", "13"])
4879
def test_swift_regex_in_exp(self):

0 commit comments

Comments
 (0)