Commit Graph

1239 Commits

Author SHA1 Message Date
Saleem Abdulrasool
114e812631 stdlib: permit builtin Collections and Unicode tests everywhere
The pthread dependency has been lifted through the Windows port
generalising the SwiftThreadExtras.  Enable building these unit test
binaries which are needed for the validation test suite.
2019-06-02 11:19:25 -07:00
Mishal Shah
d543dd9a61 Merge pull request #25136 from porglezomp-misc/fix/stdlib-unittest-race
Fix a potential race condition in StdlibUnittest
2019-05-31 14:18:30 -07:00
Ben Cohen
e9d4687e31 De-underscore @frozen, apply it to structs (#24185)
* De-underscore @frozen for enums

* Add @frozen for structs, deprecate @_fixed_layout for them

* Switch usage from _fixed_layout to frozen
2019-05-30 17:55:37 -07:00
Cassie Jones
dc395a1d1d Replace objc version of getSystemVersionPlistProperty with swift version
The comment in the function said:
// This function is implemented in Objective-C because Swift does not support
// failing initializers.
which hasn't been true since swift 1.1.
2019-05-29 18:51:31 -07:00
Cassie Jones
2d21059030 Fix an over-release in StdlibUnittest
Fixes rdar://51245681
2019-05-29 18:01:39 -07:00
Cassie Jones
e84142539c Fix a potential race condition in StdlibUnittest
StdlibUnittest uses an AtomicBool to track whether a failure has ocurred
in a test. Before this, expectFailure could have a false-positive
failure due to a race condition on the _anyExpectFailed.

The following interleaving would trigger the issue:

A: loads false
A: stores false
B: loads false
A: stores true
B: stores false
A: loads false (after body)

This causes A to see a false-positive failure.
2019-05-26 16:17:39 -07:00
Daniel Rodríguez Troitiño
69776aac35 Merge pull request #24521 from drodriguez/android-stop-leaking-fds
[android] Stop leaking FDs in parent test process.
2019-05-20 18:11:13 -07:00
Ravi Kandhadai
9be4fef53a [SIL Optimization] Add a mandatory optimization pass for optimizing
the new os log APIs based on string interpolation.
2019-05-14 18:08:59 -07:00
Ross Bayer
23a868e9f2 Merge pull request #24382 from Rostepher/usr-lib-install-name-dir
[Build System: CMake] Update the default install_name_dir to /usr/lib/swift for the standard library and overlays.
2019-05-13 15:05:22 -07:00
swift-ci
b2542a3134 Merge pull request #24127 from Gumichocopengin8/fix-build-warnings 2019-05-13 04:26:53 -07:00
Mike Ash
5b2df468fc [Reflection] Include TargetConditionals.h for WatchOS detection, not Availability.h.
While we're in there, make SwiftReflectionTest's debugLog function take an @autoclosure so we don't waste a ton of time constructing log messages that are never logged.
2019-05-08 17:51:33 -04:00
Daniel Rodríguez Troitiño
7d0b78d00f [android] Stop leaking FDs in parent test process.
In the Android paths of the spawnChild function, the parent was creating
a pipe that was never closed, which led to FD starvation. In some tests
with a lots of expected crashes, the childs will not spawn anymore since
the linker would not have enough descriptors to open the shared
libraries, while in other tests which closed the child descriptors as
part of the last test, the parent process will hang waiting those
descriptors to be closed, which will never had happened.

The solution is implement the missing parts of the code, which tried to
read from the pipe in the parent side (using select and read, taking
pieces from other parts of the code). This should match the fork/execv
path used by Android and Haiku to the spawn code used by the rest of the
platforms.

This change fixes StdlibUnittest/Stdin.swift,
stdlib/InputStream.swift.gyb,
stdlib/Collection/FlattenCollection.swift.gyb and
stdlib/Collection/LazyFilterCollection.swift.gyb, which were the last 4
tests failing in Android AArch64.
2019-05-06 17:15:07 -07:00
Keita Nonaka
0613cd3e6b Merge remote-tracking branch 'origin' into fix-build-warnings 2019-05-01 19:10:31 -04:00
Ravi Kandhadai
37f00edabc [os_log][stdlib-private] Refactor implementation and add optimization
attributes to the new os log APIs based on string interpolation so
that it can be optimized by the new OSLogOptimization compiler pass.
2019-05-01 15:42:37 -07:00
Ross Bayer
dfb2d31e74 Rename the LIBRARY_INSTALL_NAME_DIR argument in add_swift_target_library to DARWIN_INSTALL_NAME_DIR which better explains that this argument only controls the install_name_dir for Darwin platforms. 2019-04-29 16:46:09 -07:00
Ross Bayer
b855119fbe Added a new CMake cache variable to control the private standard library install_name_dir. Those libraries are not going to be installed in /usr/lib/swift and thus need to be controlled via a separate mechanism. 2019-04-29 16:46:09 -07:00
Karoy Lorentey
d9c166fdb9 Merge pull request #23832 from lorentey/foundation-hashing
[Foundation] Modernize hashing in Foundation's Swift-only types
2019-04-26 14:59:13 -07:00
Saleem Abdulrasool
83b290438c Windows: bridge BOOL to Bool
This allows the conversion of the Windows `BOOL` type to be converted to
`Bool` implicitly.  The implicit bridging allows for a more ergonomic
use of the native Windows APIs in Swift.

Due to the ambiguity between the Objective C `BOOL` and the Windows
`BOOL`, we must manually map the `BOOL` type to the appropriate type.
This required lifting the mapping entry for `ObjCBool` from the mapped
types XMACRO definition into the inline definition in the importer.

Take the opportunity to simplify the mapping code.

Adjust the standard library usage of the `BOOL` type which is now
eclipsed by the new `WindowsBool` type, preferring to use `Bool`
whenever possible.

Thanks to Jordan Rose for the suggestion to do this and a couple of
hints along the way.
2019-04-25 17:52:08 -07:00
Keita Nonaka
2771eb520c fix warnings 2019-04-18 13:11:57 -04:00
Saleem Abdulrasool
70b6bdae0d StdlibUnittest: make a var a let (NFC)
Silences a suggestion from the compiler to convert a value which is not
mutated into a `let` binding rather than a `var` binding.
2019-04-09 08:50:23 -07:00
Karoy Lorentey
68e64492ce [StdlibUnittest] checkHashable: Add opt-in support for incomplete hashes 2019-04-05 15:21:24 -07:00
Karoy Lorentey
668c1f0c6f [test] StdlibUnittest: Cosmetic changes to checkEquatable/checkHashable 2019-04-04 13:56:29 -07:00
Ravi Kandhadai
2f2afd034d [os_log][stdlib-private] Add tests for checking the correctness of
buffer and format string construction in the new OS log APIs.
2019-04-02 17:31:40 -07:00
Luciano Almeida
a62c87f6cd [stdlib] Addressing Fixme comment atomic stdlib unit test flags (#23198)
* Addressing FIXME comment making StdlibUnittest flags atomic

* Commenting store

* Fix wrong change

* Add comment

* Addressing the PR comment suggestions.

* Remove public wrong place.

* Reverting comment iff

* Update stdlib/private/StdlibUnittest/StdlibUnittest.swift

Co-Authored-By: LucianoPAlmeida <passos.luciano@outlook.com>

* File private vars
2019-03-28 12:06:02 -07:00
Mike Ash
4fb99998ae [Build] Use magic linker symbols to specify an @rpath-relative install name when targeting pre-stable-ABI OSes.
Magic symbols of the form $ld$install_name$os9.0$@rpath/libswiftCore.dylib tell the linker to use that install name when targeting that OS version. Use these symbols to specify an @rpath install name for all back-deployment libraries when targeting watchOS 2.0-5.1, iOS 7.0-12.1, and macOS 10.9-10.14.

rdar://problem/45027809
2019-03-22 10:04:39 -04:00
Michael Gottesman
384882d5f3 Merge pull request #23201 from compnerd/patience-is-not-always-a-virtue
build: introduce and switch to GYB_SOURCES
2019-03-20 13:27:32 -07:00
Saleem Abdulrasool
46bb45a51a SwiftPrivate: add isClosed property
Since the `_FDOutputStream` type does not conform to a protocol, the
required interface was missed.  The changes in
fbce6e7873 introduced a use of the
`isClosed` property which broke the Windows build.  This should fix the
windows build.
2019-03-18 08:05:26 -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
fbce6e7873 [StdlibUnittest] Allow tests to require a new process
When testing runtime lookup changes, we want to make sure each test runs in isolation. Add a new modifier, `.requireOwnProcess()`, to enable tests to guarantee they’re run in isolation.
2019-03-17 17:29:36 -07:00
swift-ci
80657a2675 Merge pull request #22914 from ravikandhadai/loggingAPI-PR 2019-03-14 19:10:53 -07:00
Ravi Kandhadai
592bca7202 [oslog] [stdlib-private] Add a prototype of the new os_log swift APIs
that accept string interpolations.

The prototypes are added to stdlib/private directory and will be
used only in tests and in experimental code.
2019-03-14 15:26:21 -07:00
Saleem Abdulrasool
8ed5c1a4bc build: introduce and switch to GYB_SOURCES
This avoids us having to pattern match every source file which should
help speed up the CMake generation.  A secondary optimization is
possible with CMake 3.14 which has the ability to remove the last
extension component without having to resort to regular expressions.  It
also helps easily identify the GYB'ed sources.
2019-03-11 13:48:54 -07:00
Saleem Abdulrasool
06ec943d89 StdlibUnittest: add a workaround for Windows \r\n
Windows uses carriage returns and newlines.  The string matching is
sensitive to this.  Simply erase carriage returns from the standard
error stream to compensate.
2019-02-28 23:13:52 -08:00
Saleem Abdulrasool
dcc10ba39f SwiftPrivateThreadExtras: address improvement suggestions
Use `ThreadHandle(bitPattern:)` rather than `unsafeBitCast` for the
conversion of the `uintptr_t` to the `HANDLE`.  Convert a variable from
`var` to `let` binding.
2019-02-16 10:31:04 -08:00
Saleem Abdulrasool
59371dba24 SwiftPrivateThreadExtras: fix casting due to API changes
The recent changes to the UnsafemutablePointer prevented the "abuse" of
the type for casting.  Switch to `unsafeBitCast`.  This should repair
the Windows build.
2019-02-13 08:13:47 -08:00
Doug Gregor
2a3b237a82 [swift-reflection-test] Strings read here are not always valid UTF-8.
The “string length” primitive was validating the string data as valid UTF-8
to get the length. However, mangled names, which get read by this operation,
are not always valid UTF-8. Just count the bytes until a ‘0’ and don’t
validate.
2019-01-27 22:03:37 -08:00
Saleem Abdulrasool
6827b68a75 SwiftPrivate: correct dependencies on Windows
Ensure that we explicitly state the dependency on WinSDK to avoid issues
in parallel builds.  Caught by the Windows nightlies.
2019-01-06 11:41:18 -08:00
Saleem Abdulrasool
bc58e5bc3f stdlib: disable abort reporting on Windows
Avoid the dialog when an assertion fails on Windows.  This is important to
ensure that the tests do not create a large number of prompts.
2019-01-03 16:56:42 -08:00
Saleem Abdulrasool
b7e21da2d0 StdlibUnittest: add a VEH for TRAP on Windows
Add a vectored exception handler for illegal instructions on Windows.
This allows us to emulate `signal(SIGTRAP, ...)`.  This allows better
coverage of tests.
2019-01-02 09:38:18 -08:00
Saleem Abdulrasool
9421d0189c StdlibUnittest: prevent abort dialog on Windows
Adjust the abort behaviour on Windows.  The aborts would cause a large
number of dialogs to appear.  This reduces the load a bit and is crucial
for getting tests to run without manual intervention.
2019-01-02 09:37:34 -08:00
Saleem Abdulrasool
3027784bf7 StdlibUnittest: add a workraound for DOS lineendings
Windows uses DOS line endings which appear through the PIPE endpoints.
We currently split on line feeds only, leaving the carriage return in
place.  Without this, the messages on the communication pipe would not
be interpreted correctly.
2019-01-02 09:37:34 -08:00
Saleem Abdulrasool
335ea14beb stdlib: port StdlibUnittest to Windows 2019-01-02 09:37:34 -08:00
Saleem Abdulrasool
7ecaeb1727 stdlib: implement _FDStreams in terms of HANDLES
Use HANDLE on Windows to create the FDStreams.  This will be used by the
standard library unit test test harness.
2018-12-21 14:19:03 -08:00
Max Moiseev
ab87c708f2 Merge pull request #21337 from moiseev/atomic-int-reshuffle
[stdlib] tee _stdlib_AtomicInt > SwiftPrivate
2018-12-19 10:00:39 -08:00
Max Moiseev
f370c676c0 Merge pull request #20962 from compnerd/libc-extras
PrivateLibcExtras: Port to Windows
2018-12-19 10:00:15 -08:00
Maxim Moiseev
165fe328c3 [stdlib] tee _stdlib_AtomicInt > SwiftPrivate
Turns out some people used this type despite it being prefixed with
`_stdlib_`, so we have to keep it, with an obsoletion message this time.
Second copy of the same type is kept available past Swift 5 in
SwiftPrivate for use in tests.
2018-12-18 16:12:47 -08:00
Saleem Abdulrasool
39f2ac98b7 SwiftPrivate: fix dependencies on Windows
This module needs MSVCRT and WinSDK on Windows.  Track the dependencies.
2018-12-16 22:26:44 -08:00
Saleem Abdulrasool
d70911e1ff SwiftPrivateLibcExtras: port to Windows
Enable the libc extras to be built for Windows.  This is a dependency
for StdlibUnittests.
2018-12-16 22:11:07 -08:00
Saleem Abdulrasool
3225e36d63 stdlib: reorder add_subdirectory to repair the Windows build
Due to the horrible attrocities against software of the attempt to perform
cross-compilation in the swift build system, we need to emulate the linking
behaviour for Windows with the link against the import library.  The emulation
requires the custom creation of import library targets.  In order to actually
get the linking semantics correct, the dependendency targets must be created
prior to use (unlike standard CMake).  The reordering ensures that we get
correct linkage when building for Windows.

Perform a simple optimization to avoid a number of string comparisions for the
host system.
2018-12-14 13:56:16 -08:00
Ben Cohen
11769d2494 Add tests for withContiguousStorageIfAvailable 2018-12-07 17:30:13 -08:00