Commit Graph

719 Commits

Author SHA1 Message Date
Mike Ash
6746911dde [Test] Add availability to the GenericMangled test in objc_getClass.swift
This is a new test in Swift 5.1 that is not expected to pass when running
with the Swift 5.0 runtime library.

rdar://problem/50175915
2019-05-21 10:26:02 -04:00
Slava Pestov
ddf6492d63 Remove -target from test/Interpreter/SDK/archive_attributes.swift
It was broken on 10.9, again...

Fixes <rdar://problem/50897660>.
2019-05-17 15:28:06 -04:00
Slava Pestov
1ca80f93f4 test/Interpreter/SDK/archive_attributes.swift only work on the host or simulator
Fixes <rdar://problem/50897246>.
2019-05-17 15:07:39 -04:00
Slava Pestov
49b19f5205 Merge pull request #24833 from slavapestov/cross-platform-stable-abi-tests
Run stable ABI tests on all Apple platforms
2019-05-16 21:09:49 -04:00
Bob Wilson
a579af3d07 Merge pull request #24832 from bob-wilson/rdar50175915
[Test] Add availability to the ResilientNSObject test in objc_getClass.swift
2019-05-16 15:11:27 -07:00
Slava Pestov
5d66bb810a Run stable ABI tests on all Apple platforms
A number of tests exercise features only available in Apple OSes that
shipped with Swift 5.0 in the OS; this includes the following versions:

- macOS 10.14.4
- iOS 12.2
- tvOS 12.2
- watchOS 5.2

Previously these tests were restricted to running on macOS only, with
an explicit -target x86_64-apple-macosx10.14.4. To get better test
coverage, add a new %target-stable-abi-triple substitution which
expands to a triple with the correct OS version on all Apple platforms.

On non-Apple platforms, this is the same as %target-variant-triple,
but for now any test that uses this exercises Apple platform features
anyway.

One caveat is that since iOS 12.2 does not have a 32-bit slice, we
have to skip any tests that use -target %target-stable-abi-triple
on this platform. A new swift_stable_abi feature flag can be tested
with 'REQUIRES: swift_stable_abi'. To get maximum test coverage,
I split off a 'stable_abi' version of a few tests that build with both
an old and new deployment target. This allows the old deployment
target case to still be tested on 32-bit iOS.
2019-05-16 17:02:06 -04:00
Bob Wilson
dbde6aa65e [Test] Add availability to the ResilientNSObject test in objc_getClass.swift
This is a new test in Swift 5.1 that is not expected to pass when running
with the Swift 5.0 runtime library.

rdar://problem/50175915
2019-05-16 09:43:53 -07:00
Erik Eckstein
3e30d43e10 tests: disable check_class_for_archiving checks for older OSes
rdar://problem/50504765
2019-05-15 16:44:09 -07:00
Mike Ash
0a3b722bf9 Merge pull request #24688 from mikeash/swift-nativensxxxcoding-test-availability
[Test] Guard SwiftNativeNSXXXCoding tests behind #available(9999).
2019-05-13 12:06:18 -04:00
Slava Pestov
cc53fd9518 Fix archive_attributes test to work on macOS 10.9
That OS doesn't have objc_readClassPair(). This test uses -target to
explicitly select a newer deployment target and then runs the binary
on an old OS to test the behavior. However this means arclite won't
get linked in unless we also pass in -link-objc-runtime.

Fixes <rdar://problem/50610877>.
2019-05-10 14:54:34 -04:00
Mike Ash
5a8a0a816e [Test] Guard SwiftNativeNSXXXCoding tests behind #available(9999).
These tests fail when run against older runtimes since they don't have the fix.

rdar://problem/50504800
2019-05-10 14:51:05 -04:00
Mike Ash
3ad6e46930 [Stdlib] Fix warnings about designated initializers in SwiftNativeXXX classes. 2019-05-06 17:15:53 -04:00
Jordan Rose
517f5d6b6a [ClangImporter] Retire the term "adapter" in favor of "overlay" (#24427)
Way back in Swift 1 I was trying to draw a distinction between
"overlays", separate libraries that added Swift content to an existing
Objective-C framework, and "the Swift part of a mixed-source
framework", even though they're implemented in almost exactly the same
way. "Adapter module" was the term that covered both of those. In
practice, however, no one knew what "adapter" meant. Bring an end to
this confusion by just using "overlay" within the compiler even for
the mixed-source framework case.

No intended functionality change.
2019-05-03 11:11:58 -07:00
Mike Ash
8d2b1bbf7b Merge pull request #24394 from mikeash/decode-the-undecodable
[Stdlib] Make the SwiftNativeNSXXXBase classes gracefully handle being decoded with NSKeyedUnarchiver.
2019-05-02 10:06:06 -04:00
Slava Pestov
6d7d13fceb IRGen: Disable eager initialization of NSCoding adopters on newer targets
If a class does not have a custom @objc name, objc_getClass() can find
it at runtime by calling the Swift runtime's metadata demangler hook.

This avoids the static initializer on startup. If the class has a
custom runtime name we still need the static initializer unfortunately.

Fixes <rdar://problem/49660515>.
2019-05-01 17:43:58 -04:00
Mike Ash
7506e9c4f8 [Stdlib] Make the SwiftNativeNSXXXBase classes gracefully handle being decoded with NSKeyedUnarchiver.
These would never be decoded in normal use, but it's possible to construct an archive that will attempt to decode them. Without this override, that throws an exception or worse.

rdar://problem/48429185
2019-05-01 10:04:14 -04:00
Slava Pestov
7c8641c497 Fix formatting nit in objc_getClass test 2019-04-19 17:39:51 -04:00
Harlan Haskins
150ad99457 [ModuleInterfaces] Replace 'module file' with 'compiled module'
...only in diagnostics. And make the tests pass.

rdar://49359734
2019-04-11 18:05:09 -07:00
Brent Royal-Gordon
7ae331dbca [NFC] Pick a few nits for Jordan 2019-04-10 23:17:04 -07:00
Arnold Schwaighofer
252738af5b Fix test case 2019-03-21 13:50:53 -07:00
Arnold Schwaighofer
e113ef8c93 Add a mode to test implicit dynamic with private imports 2019-03-20 14:34:01 -07:00
Harlan Haskins
e8d474aa11 Merge pull request #23343 from harlanhaskins/mangled-lassi
[Demangle] Check for old-style mangling in getObjCClassByMangledName
2019-03-17 22:24:34 -07:00
Harlan Haskins
09bdaa35c5 [test] Test looking up resilient NSObject subclasses
Add tests to make sure we can look up resilient NSObject subclasses in the ObjC runtime.
2019-03-17 17:29:36 -07:00
swift-ci
497e94e89d Merge pull request #23235 from mikeash/remove-stable-abi-bit-configuration 2019-03-15 15:31:58 -07:00
Slava Pestov
1159af50d9 Rename -enable-resilience to -enable-library-evolution and make it a driver flag
Fixes <rdar://problem/47679085>.
2019-03-14 22:24:26 -04:00
Mike Ash
597dcd8f3f [Stdlib][Frontend][CMake] Remove SWIFT_DARWIN_ENABLE_STABLE_ABI_BIT option, make it permanently on. 2019-03-13 09:31:50 -04:00
Saleem Abdulrasool
dc2fa3add1 test: alterations for Windows
This brings the Interpreter pass rate on Windows to 100%
2019-02-17 10:38:59 -08:00
Slava Pestov
b64db715a8 IRGen: Remove -enable-class-resilience staging flag 2019-02-08 14:22:00 -05:00
Daniel Rodríguez Troitiño
d08b46c47e [tests] Standarize the checks for Darwin, Glibc and MSVCRT.
Different tests used different os checks for importing Darwin, Glibc and
MSVCRT. This commit use the same pattern for importing those libraries,
in order to avoid the #else branches of the incorrect patterns to be
applied to the wrong platform. This was very normal for Android, which
normally should follow the Linux branches, but sometimes was trying to
import Darwin or not importing anything.

The standarized pattern imports Darwin for macOS, iOS, tvOS and watchOS.
It imports Glibc for Linux, FreeBSD, PS4, Android, Cygwin and Haiku; and
imports MSVCRT for Windows. If a new platform is introduced, the else
branch will report an error, so the new platform can be added to one of
the branches (or maybe add a new specific branch).

In some cases  the standard pattern was modified because some test required
it (importing extra modules, or extra type aliases), and in some other
cases some branches were removed because the test will not have used
them (but it is not exhaustive, so there might be some unnecessary
branches).

This should, at least, fix three tests for Android (the three
dynamic_replacement*.swift ones).
2019-02-06 10:51:55 -08:00
Mishal Shah
42633218c5 Update master to build with Xcode 10.2 beta 1 2019-01-31 14:48:29 -08:00
Saleem Abdulrasool
d2aad4121c test: port most of the interpreter tests to Windows
This ports most of the interpreter tests to Windows.  A few remaining
failures need to be diagnosed still.
2019-01-15 18:47:13 -08:00
Jordan Rose
425c190086 Restore initializing entry points for @objc convenience initializers (#21815)
This undoes some of Joe's work in 8665342 to add a guarantee: if an
@objc convenience initializer only calls other @objc initializers that
eventually call a designated initializer, it won't result in an extra
allocation. While Objective-C /allows/ returning a different object
from an initializer than the allocation you were given, doing so
doesn't play well with some very hairy implementation details of
compiled nib files (or NSCoding archives with cyclic references in
general).

This guarantee only applies to
(1) calling `self.init`
(2) where the delegated-to initializer is @objc
because convenience initializers must do dynamic dispatch when they
delegate, and Swift only stores allocating entry points for
initializers in a class's vtable. To dynamically find an initializing
entry point, ObjC dispatch must be used instead.

(It's worth noting that this patch does NOT check that the calling
initializer is a convenience initializer when deciding whether to use
ObjC dispatch for `self.init`. If we ever add peer delegation to
designated initializers, which is totally a valid feature, that should
use static dispatch and therefore should not go through objc_msgSend.)

This change doesn't /always/ result in fewer allocations; if the
delegated-to initializer ends up returning a different object after
all, the original allocation was wasted. Objective-C has the same
problem (one of the reasons why factory methods exist for things like
NSNumber and NSArray).

We do still get most of the benefits of Joe's original change. In
particular, vtables only ever contain allocating initializer entry
points, never the initializing ones, and never /both/ (which was a
thing that could happen with 'required' before).

rdar://problem/46823518
2019-01-14 13:06:50 -08:00
Greg Parker
7200e109d7 [runtime] Add tests of pre-stable ABI objects with the stable ABI runtime (#21403)
* [test] Fix objc_old_swift when objc/objc-internal.h is not in the SDK.
2018-12-20 18:32:03 -08:00
Saleem Abdulrasool
e94abbca4b Merge pull request #21279 from compnerd/rpath
test: define and use `%target-rpath`
2018-12-17 12:37:30 -08:00
Saleem Abdulrasool
5f660ba7e7 Interpreter: mark some tests as REQUIRES: objc_interop
These tests require the ObjC Foundation framework currently (although it
should be possible have them use the swift corelibs Foundation project
to satisfy this requirement).  Marking the tests indicates that these
tests do not have the dependencies to run on Windows.
2018-12-14 20:41:47 -08:00
Saleem Abdulrasool
d77801abaf test: define and use %target-rpath
Create a new capturing substitution for adding a rpath to a target
library.  This is needed as Windows doesn't really support the concept
of a rpath.  This also makes it possible to remove the parameter from
the command line on windows.
2018-12-12 19:51:08 -08:00
Saleem Abdulrasool
ed1ec54958 test: make %target-library-name work in captures
Thanks to @jrose for the hint about the substitution ordering, the new
substitution now works even inside the capture group.  Replace the
remaining uses to the new macro.
2018-12-12 10:09:58 -08:00
Saleem Abdulrasool
8968fcad5f test: create and use target-library-name 2018-12-12 08:37:59 -08:00
Saleem Abdulrasool
b212229db1 test: add and use prefix substitutions for libraries
The naming convention is different on Windows than on Unix-like
environments.  In order to follow the convention we need to substitute
the prefix and the suffix.  Take the opportunity to rename the
`target-dylib-extension` to the CMake-like variable
`target-shared-library-suffix` and introduce
`target-shared-library-prefix`.  This helps linking the test suite
binaries on Windows.
2018-12-11 15:56:06 -08:00
Greg Parker
70bbeaab78 [runtime] Register a hook for class name lookup from libobjc (#20650)
libobjc needs to look up classes by name. Some Swift classes, such as
instantiated generics and their subclasses, are created only on demand.
Now a by-name lookup from libobjc counts as a demand for those classes.

rdar://problem/27808571
2018-11-29 17:06:28 -08:00
Slava Pestov
38fdb6b7ff Update various tests to not use Swift 3 code
Completely mechanical changes:

- Explicit @objc in a few places
- Some imported APIs changed
- For the mix-and-match tests, just test version 4/5 instead of 3/4
2018-10-26 20:15:01 -04:00
Jordan Rose
e596e1f8ea Merge pull request #19702 from jrose-apple/who-remembers-mavericks
[test] Tweak some tests so that they run consistently on OS X 10.9
2018-10-22 15:47:08 -07:00
Slava Pestov
0b0d7dcff9 Sema: Remove most of the remaining Swift 3 support 2018-10-08 18:43:52 -07:00
Jordan Rose
21fe402c82 [test] Disable some tests on OS X 10.9 that require a newer Foundation 2018-10-03 16:54:38 -07:00
Jordan Rose
b5176939ca [test] Tweak some tests so that they run consistently on OS X 10.9 2018-10-03 16:54:38 -07:00
Jordan Rose
bf5133d986 Merge pull request #19485 from jrose-apple/disintegrated
Rework the integrated REPL to use separate modules for every line
2018-09-26 09:04:50 -07:00
Jordan Rose
2b5a2ad84c Rework the integrated REPL to use separate modules for every line
...like LLDB does, instead of parsing into a single SourceFile.
This does break some functionality:

- no more :dump_ast
- no redeclaration checking, but no shadowing either---redeclarations
  just become ambiguous
- pretty much requires EnableAccessControl to be off, since we don't
  walk decls to promote them to 'public'

...but it allows us to remove a bit of longstanding support for
type-checking / SILGen-ing / IRGen-ing only part of a SourceFile that
was only used by the integrated REPL.

...which, need I remind everyone, is still /deprecated/...but sometimes
convenient. So most of it still works.
2018-09-25 09:13:52 -07:00
Mike Ash
798edb9d0e [Runtime][Stdlib][Overlays] Rename various Objective-C classes and methods that would conflict when loading old Swift libraries into a process alongside ABI-stable libraries.
rdar://problem/35768222
2018-09-13 16:55:10 -04:00
Jordan Rose
01a0de27ec [test] Update for remote-run-ing tests on a different macOS (#18966)
Most of this is just "remember to specify the inputs and outputs on
the command line, so remote-run can see them". A bit is "prefix
environment variables with '%env-'". And the last few are "yeah,
this was never going to work in a remote environment".

In the few cases where I couldn't think of anything reasonable, I just
marked the test as "UNSUPPORTED: remote_run", a new "feature".
2018-08-27 14:50:40 -07:00
Arnold Schwaighofer
6eca97add6 Codesign test/Interpreter 2018-08-10 06:58:40 -07:00