Skip to content

Commit 2686010

Browse files
committed
Add test for missing pch files to document shortcoming
1 parent c4142a2 commit 2686010

File tree

5 files changed

+68
-0
lines changed

5 files changed

+68
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
public func foo(_ x : Int) -> Int {
2+
return x + x
3+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
SWIFT_SOURCES := main.swift
2+
SWIFT_OBJC_INTEROP := 1
3+
SWIFTFLAGS_EXTRAS = -I$(BUILDDIR)
4+
LD_EXTRAS = -L$(BUILDDIR) -lFoo
5+
6+
all: libFoo.dylib $(EXE)
7+
8+
include Makefile.rules
9+
10+
OVERLAY := $(BUILDDIR)/overlay.yaml
11+
lib%.dylib: %.swift
12+
echo "struct S {};">$(BUILDDIR)/header.h
13+
$(MAKE) MAKE_DSYM=$(MAKE_DSYM) CC=$(CC) SWIFTC=$(SWIFTC) \
14+
ARCH=$(ARCH) DSYMUTIL=$(DSYMUTIL) \
15+
BASENAME=$(shell basename $< .swift) \
16+
SWIFT_BRIDGING_HEADER=header.h \
17+
SWIFT_PRECOMPILE_BRIDGING_HEADER=YES \
18+
VPATH=$(SRCDIR) -I $(SRCDIR) -f $(SRCDIR)/dylib.mk all
19+
rm -f $(OVERLAY)
20+
21+
clean::
22+
$(MAKE) MAKE_DSYM=$(MAKE_DSYM) CC=$(CC) SWIFTC=$(SWIFTC) \
23+
ARCH=$(ARCH) DSYMUTIL=$(DSYMUTIL) \
24+
BASENAME=$(shell basename $< .swift) \
25+
VPATH=$(SRCDIR) -I $(SRCDIR) -f $(SRCDIR)/dylib.mk clean
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import lldb
2+
from lldbsuite.test.lldbtest import *
3+
from lldbsuite.test.decorators import *
4+
import lldbsuite.test.lldbutil as lldbutil
5+
import unittest2
6+
import os
7+
8+
class TestSwiftMissingVFSOverlay(TestBase):
9+
mydir = TestBase.compute_mydir(__file__)
10+
11+
NO_DEBUG_INFO_TESTCASE = True
12+
13+
def setUp(self):
14+
TestBase.setUp(self)
15+
16+
# Don't run ClangImporter tests if Clangimporter is disabled.
17+
@skipIf(setting=("symbols.use-swift-clangimporter", "false"))
18+
@skipUnlessDarwin
19+
@swiftTest
20+
def test(self):
21+
"""This used to be a test for a diagnostic, however,
22+
this is no longer an unrecoverable error"""
23+
self.build()
24+
os.unlink(self.getBuildArtifact("header.pch"))
25+
lldbutil.run_to_source_breakpoint(
26+
self, "break here", lldb.SBFileSpec("main.swift"),
27+
extra_images=["Foo"]
28+
)
29+
# FIXME: This crashes the compiler while trying to diagnose the
30+
# missing file (because the source location is inside the missing file).
31+
#self.expect("expr y", substrs=["1"])
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
DYLIB_ONLY := YES
2+
DYLIB_NAME := $(BASENAME)
3+
DYLIB_SWIFT_SOURCES := $(DYLIB_NAME).swift
4+
5+
include Makefile.rules
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import Foo
2+
3+
let y = foo(21)
4+
print(y) // break here

0 commit comments

Comments
 (0)