Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
20 changes: 20 additions & 0 deletions lldb/packages/Python/lldbsuite/test/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -984,6 +984,26 @@ def is_not_swift_compatible(self):

return skipTestIfFn(is_not_swift_compatible)(func)

def skipEmbeddedSwift(func):
def skip_fn(swift_embedded=None, **kwargs):
if swift_embedded == "swift_embedded":
return "not supported in embedded Swift"
return None
return _skipForVariant("swift_embedded", skip_fn, func)

def skipEmbeddedSwiftOnLinux(func):
def skip_fn(swift_embedded=None, **kwargs):
if swift_embedded == "swift_embedded" and lldbplatformutil.getPlatform() == "linux":
return "not supported in embedded Swift on Linux"
return None
return _skipForVariant("swift_embedded", skip_fn, func)

def skipUnlessEmbeddedSwift(func):
def skip_fn(swift_embedded=None, **kwargs):
if swift_embedded != "swift_embedded":
return "Only supported in embedded Swift"
return None
return _skipForVariant("swift_embedded", skip_fn, func)

def skipIfHostIncompatibleWithTarget(func):
"""Decorate the item to skip tests when the host and target are incompatible."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ def did_crash(self, result):
error = self.get_stream_data(result)
print("Crash Error: {}".format(error))

@skipEmbeddedSwift
@swiftTest
def test_playgrounds(self):
# Build
Expand Down
19 changes: 19 additions & 0 deletions lldb/packages/Python/lldbsuite/test/lldbtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,8 @@ def setUpClass(cls):
if not cls.mydir:
raise Exception("Subclasses must override the 'mydir' attribute.")

cls.extra_make_flags = {}

# Save old working directory.
cls.oldcwd = os.getcwd()

Expand Down Expand Up @@ -1538,6 +1540,8 @@ def build(
if command is None:
raise Exception("Don't know how to build binary")

command += [f"{k}={v}" for k, v in self.extra_make_flags.items()]

self.runBuildCommand(command)

def runBuildCommand(self, command):
Expand Down Expand Up @@ -1943,6 +1947,14 @@ def _swift_module_importer_setup(test_instance, variant_value):
elif variant_value == "clangimporter":
test_instance.runCmd("settings set symbols.use-swift-clangimporter true")

def _embedded_swift_setup(test_instance, variant_value):
if variant_value == "swift_embedded":
test_instance.extra_make_flags["SWIFT_EMBEDDED_MODE"] = "1"
elif variant_value == "swift":
test_instance.extra_make_flags["SWIFT_EMBEDDED_MODE"] = "0"
else:
assert False, f"Unknown variant: {variant_value}"


_test_variants = [
TestVariant(
Expand All @@ -1952,6 +1964,13 @@ def _swift_module_importer_setup(test_instance, variant_value):
setup_fn=_swift_module_importer_setup,
attrs_to_preserve=("debug_info",),
),
TestVariant(
name="swift_embedded",
values=test_categories.embedded_swift_categories,
predicate=lambda m: getattr(m, "__swift_test__", False),
setup_fn=_embedded_swift_setup,
attrs_to_preserve=("debug_info",),
),
]


Expand Down
7 changes: 7 additions & 0 deletions lldb/packages/Python/lldbsuite/test/test_categories.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
"dwarfimporter": True,
}

embedded_swift_categories = {
"swift": True,
"swift_embedded": True,
}

all_categories = {
"basic_process": "Basic process execution sniff tests.",
"cmdline": "Tests related to the LLDB command-line interface",
Expand Down Expand Up @@ -56,6 +61,8 @@
"watchpoint": "Watchpoint-related tests",
"clangimporter": "Tests run with the Swift ClangImporter",
"dwarfimporter": "Tests run with the Swift DWARFImporter",
"swift_embedded": "Tests are compiled as embedded Swift",
"swift": "Tests are compiled as normal Swift",
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import lldbsuite.test.lldbutil as lldbutil

class TestCase(TestBase):
@skipEmbeddedSwift
@swiftTest
@expectedFailureWindows
def test_swift_po_address(self):
Expand All @@ -21,6 +22,7 @@ def test_swift_po_address(self):
self.expect(f"dwim-print -O -- 0x{hex_addr}", patterns=[f"Object@0x0*{hex_addr}"])
self.expect(f"dwim-print -O -- {addr}", patterns=[f"Object@0x0*{hex_addr}"])

@skipEmbeddedSwift
@swiftTest
@expectedFailureWindows
def test_swift_po_non_address_hex(self):
Expand All @@ -31,6 +33,7 @@ def test_swift_po_non_address_hex(self):
)
self.expect(f"dwim-print -O -- 0x1000", substrs=["4096"])

@skipEmbeddedSwift
@swiftTest
@expectedFailureWindows
def test_print_swift_object_does_not_show_name(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@


class TestCase(TestBase):
@skipEmbeddedSwift
@swiftTest
@skipUnlessDarwin
def test_objc_self(self):
self.build()
lldbutil.run_to_source_breakpoint(self, "check self", lldb.SBFileSpec("main.swift"))
self.expect("frame variable _prop", startstr="(Int) _prop = 30")

@skipEmbeddedSwift
@swiftTest
@skipUnlessDarwin
def test_objc_self_capture_idiom(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class AsanSwiftTestCase(lldbtest.TestBase):

mydir = lldbtest.TestBase.compute_mydir(__file__)

@skipEmbeddedSwift
@swiftTest
@skipIfWindows
@skipIfLinux
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@


class TestSwiftErrorBreakpoint(TestBase):
@skipEmbeddedSwift
@decorators.skipIfLinux # <rdar://problem/30909618>
@swiftTest
@expectedFailureWindows
Expand All @@ -28,20 +29,23 @@ def test_swift_error_no_typename(self):
self.build()
self.do_tests(None)

@skipEmbeddedSwift
@swiftTest
@expectedFailureWindows
def test_swift_error_matching_base_typename(self):
"""Tests that swift error throws are correctly caught by the Swift Error breakpoint"""
self.build()
self.do_tests("EnumError")

@skipEmbeddedSwift
@swiftTest
@expectedFailureWindows
def test_swift_error_matching_full_typename(self):
"""Tests that swift error throws are correctly caught by the Swift Error breakpoint"""
self.build()
self.do_tests("a.EnumError")

@skipEmbeddedSwift
@swiftTest
@skipIfWindows
def test_swift_error_bogus_typename(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@


class TestCase(TestBase):
@skipEmbeddedSwift
@swiftTest
@expectedFailureWindows
def test(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@


class PrintObjectArrayTestCase(TestBase):
@skipEmbeddedSwift
@skipUnlessDarwin
def test_print_array(self):
"""Test that expr -O -Z works"""
self.build()
self.printarray_data_formatter_commands()

@skipEmbeddedSwift
@skipUnlessDarwin
def test_print_array_no_const(self):
"""Test that expr -O -Z works"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
from lldbsuite.test.decorators import *

lldbinline.MakeInlineTest(
__file__, globals(), decorators=[swiftTest, expectedFailureWindows]
__file__, globals(), decorators=[skipEmbeddedSwift,
swiftTest, expectedFailureWindows]
)
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

class TestCase(TestBase):

@skipEmbeddedSwift
@swiftTest
@skipUnlessFoundation
def test(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@


class TestCase(TestBase):
@skipEmbeddedSwift
@skipUnlessFoundation
@swiftTest
def test_swift_date_formatters(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@


class TestCase(TestBase):
@skipEmbeddedSwift
@skipUnlessFoundation
@swiftTest
def test_swift_string_index_formatters(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@


class TestCase(TestBase):
@skipEmbeddedSwift
@swiftTest
@expectedFailureWindows
def test_swift_substring_formatters(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@


class MTCSwiftPropertyTestCase(TestBase):
@skipEmbeddedSwift
@skipUnlessDarwin
@swiftTest
def test(self):
Expand Down
1 change: 1 addition & 0 deletions lldb/test/API/functionalities/mtc/swift/TestSwiftMTC.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@


class MTCSwiftTestCase(TestBase):
@skipEmbeddedSwift
@skipUnlessDarwin
@swiftTest
def test(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def setUp(self):
self.listener = lldbutil.start_listening_from(self.broadcaster,
lldb.SBDebugger.eBroadcastBitProgress)

@skipEmbeddedSwift
# Don't run ClangImporter tests if Clangimporter is disabled.
@skipIf(setting=('symbols.use-swift-clangimporter', 'false'))
@skipUnlessDarwin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class SwiftRuntimeReportingExclusivityViolationTestCase(lldbtest.TestBase):
mydir = lldbtest.TestBase.compute_mydir(__file__)

@decorators.swiftTest
@decorators.skipEmbeddedSwift
@decorators.skipIfLinux
@decorators.expectedFailureWindows
def test_swift_runtime_reporting(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class TsanSwiftAccessRaceTestCase(lldbtest.TestBase):

mydir = lldbtest.TestBase.compute_mydir(__file__)

@skipEmbeddedSwift
@swiftTest
@skipIfWindows
@skipIfLinux
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class TsanSwiftTestCase(lldbtest.TestBase):

mydir = lldbtest.TestBase.compute_mydir(__file__)

@skipEmbeddedSwift
@swiftTest
@skipIfWindows
@skipIfLinux
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
from lldbsuite.test.decorators import *

lldbinline.MakeInlineTest(
__file__, globals(), decorators=[swiftTest, expectedFailureWindows]
__file__, globals(), decorators=[skipEmbeddedSwift,
swiftTest, expectedFailureWindows]
)
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def check_variable(self, name, is_reference, contents = 0):
self.assertSuccess(error)


@skipEmbeddedSwift
@swiftTest
@expectedFailureWindows
def test(self):
Expand Down
1 change: 1 addition & 0 deletions lldb/test/API/lang/swift/any/TestSwiftAnyType.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class TestSwiftAnyType(lldbtest.TestBase):

mydir = lldbtest.TestBase.compute_mydir(__file__)

@skipEmbeddedSwift
@swiftTest
@expectedFailureWindows
def test_any_type(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
from lldbsuite.test.decorators import *

lldbinline.MakeInlineTest(
__file__, globals(), decorators=[swiftTest, expectedFailureWindows]
__file__, globals(), decorators=[skipEmbeddedSwift,
swiftTest, expectedFailureWindows]
)
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,22 @@

@skipIfWindows
class TestArchetypeInConditionalBreakpoint(TestBase):
@skipEmbeddedSwift
@swiftTest
def test_stops_free_function(self):
self.stops("break here for free function")

@skipEmbeddedSwift
@swiftTest
def test_doesnt_stop_free_function(self):
self.doesnt_stop("break here for free function")

@skipEmbeddedSwift
@swiftTest
def test_stops_class(self):
self.stops("break here for class")

@skipEmbeddedSwift
@swiftTest
def test_doesnt_stop_class(self):
self.doesnt_stop("break here for class")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

class TestArchetypeInExpression(TestBase):

@skipEmbeddedSwift
@swiftTest
@expectedFailureWindows
def test(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@


class TestSwiftArchetypeResolution(TestBase):
@skipEmbeddedSwift
@swiftTest
@expectedFailureWindows
def test_swift_archetype_resolution(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
from lldbsuite.test.decorators import *

lldbinline.MakeInlineTest(
__file__, globals(), decorators=[swiftTest, expectedFailureWindows]
__file__, globals(), decorators=[skipEmbeddedSwift,
swiftTest, expectedFailureWindows]
)
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import lldbsuite.test.lldbinline as lldbinline
from lldbsuite.test.decorators import *

lldbinline.MakeInlineTest(__file__, globals(), decorators=[swiftTest, skipUnlessFoundation])
lldbinline.MakeInlineTest(__file__, globals(), decorators=[skipEmbeddedSwift,
swiftTest, skipUnlessFoundation])
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
from lldbsuite.test.decorators import *

lldbinline.MakeInlineTest(
__file__, globals(), decorators=[swiftTest, expectedFailureWindows]
__file__, globals(), decorators=[skipEmbeddedSwift,
swiftTest, expectedFailureWindows]
)
3 changes: 2 additions & 1 deletion lldb/test/API/lang/swift/array_enum/TestArrayEnum.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
from lldbsuite.test.decorators import *

lldbinline.MakeInlineTest(
__file__, globals(), decorators=[swiftTest, expectedFailureWindows]
__file__, globals(), decorators=[skipEmbeddedSwift,
swiftTest, expectedFailureWindows]
)
Loading