Skip to content

Add a testcase for protected imports. #9456

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 22, 2024
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lldb/test/API/lang/swift/import_spi/A.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@_spi(Private) import B
public class FromA {
public init() {}
@_spi(Private) public var a : Int { get { return 42 } }
@_spi(Private) public var b : FromB { get { return FromB() } }
}
4 changes: 4 additions & 0 deletions lldb/test/API/lang/swift/import_spi/B.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
public class FromB {
public init() {}
public let c = 42
}
24 changes: 24 additions & 0 deletions lldb/test/API/lang/swift/import_spi/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
SWIFT_SOURCES := main.swift
MODULENAME = Main
SWIFTFLAGS_EXTRAS = -I$(BUILDDIR)
LD_EXTRAS = -L$(BUILDDIR) -lA -lB

all: A.swiftmodule $(EXE)

include Makefile.rules

A.swiftmodule: $(SRCDIR)/A.swift B.swiftmodule
$(MAKE) -f $(MAKEFILE_RULES) \
DYLIB_ONLY=YES \
DYLIB_NAME=A \
DYLIB_SWIFT_SOURCES=A.swift \
DYLIB_MODULENAME=A \
SWIFTFLAGS_EXTRAS=-I$(BUILDDIR) \
LD_EXTRAS="-L$(BUILDDIR) -lB"

B.swiftmodule: $(SRCDIR)/B.swift
$(MAKE) -f $(MAKEFILE_RULES) \
DYLIB_ONLY=YES \
DYLIB_NAME=B \
DYLIB_SWIFT_SOURCES=B.swift \
DYLIB_MODULENAME=B
19 changes: 19 additions & 0 deletions lldb/test/API/lang/swift/import_spi/TestSwiftImportSPI.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import lldb
from lldbsuite.test.decorators import *
import lldbsuite.test.lldbtest as lldbtest
import lldbsuite.test.lldbutil as lldbutil
import os


class TestSwiftImportSPI(lldbtest.TestBase):
@swiftTest
def test(self):
"""Test SPI imports"""
self.build()
target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(
self, 'break here', lldb.SBFileSpec('main.swift'),
extra_images=['A', 'B'])
# a.b returns a B FromB, which is an @_spi(Private) import of A.
self.expect("expression -- a.b.c", substrs=['42'])
# a.a itself is marked @_spi(Private).
self.expect("expression -- a.a", substrs=['42'])
4 changes: 4 additions & 0 deletions lldb/test/API/lang/swift/import_spi/main.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import A

let a = FromA()
print("break here")