Commit Graph

67 Commits

Author SHA1 Message Date
Meghana Gupta
222ee7389a Diagnose @_lifetime on targets that are Escapable
Lifetime dependencies can be attached to ~Escapable types only
2025-07-22 06:00:38 -07:00
Guillaume Lessard
6c588dc908 Merge pull request #82701 from glessard/rdar154776967-generalize-expectNil
[stdlibUnittest] generalize `expectNil(_:)`
2025-07-03 01:16:24 -07:00
Konrad 'ktoso' Malawski
e32d221e2a [StdlibUnittest] Warn if no tests were executed 2025-07-02 19:38:50 +09:00
Guillaume Lessard
987fedf46a [stdlibUnittest] generalize expectNil(_:) 2025-07-01 15:16:49 -07:00
Allan Shortlidge
71eede247f StdlibUnittest: Use @_lifetime instead of @lifetime.
Resolves a warning.
2025-06-11 12:49:43 -07:00
Guillaume Lessard
5895077382 [stdlibUnittest] generalize expectNotNil(_:)
Generalizes it for non-copyable and non-escapable values.
2025-06-06 09:14:27 -07:00
Guillaume Lessard
df33b83c78 [StdlibUnittest] add a TestRunPredicate for WASI 2025-03-21 15:47:25 -07:00
Nate Cook
ff86a69dd7 Add a StdlibUnitTest modifier for requiring a stdlib version (#79838)
It would be great if this could also set the availability for the `code:`
block, but this at least cuts out some boilerplate.
2025-03-08 13:07:20 -06:00
Allan Shortlidge
17fd27554b stdlib: Adopt internal imports to suppress some warnings in tests. 2024-11-13 09:51:29 -08:00
Daniel Rodríguez Troitiño
63022333d8 [unittest] Disambiguate references to errno (#77155)
In Xcode 16 SDKs there seem to be two `errno` visible for some files,
one in the `Darwin` module, and one in the `_errno` module (which seems
new for this Xcode version).

Disambiguate the references by prepending `Darwin`, which should be the
one that was being used before Xcode 16 SDKs.
2024-10-22 15:48:56 -07:00
Alex Lorenz
57b89d5303 [android] add an android NDK Swift overlay module, and use it instead of Glibc 2024-05-28 12:57:38 -07:00
Artem Chikin
1f14158a1d Introduce VisionOS Platform
This change introduces a new compilation target platform to the Swift compiler - visionOS.

- Changes to the compiler build infrastrucuture to support building compiler-adjacent artifacts and test suites for the new target.
- Addition of the new platform kind definition.
- Support for the new platform in language constructs such as compile-time availability annotations or runtime OS version queries.
- Utilities to read out Darwin platform SDK info containing platform mapping data.
- Utilities to support re-mapping availability annotations from iOS to visionOS (e.g. 'updateIntroducedPlatformForFallback', 'updateDeprecatedPlatformForFallback', 'updateObsoletedPlatformForFallback').
- Additional tests exercising platform-specific availability handling and availability re-mapping fallback code-path.
- Changes to existing test suite to accomodate the new platform.
2024-04-10 09:38:02 -07:00
Guillaume Lessard
0c916f507d [stdlib] replace uses of String(validatingUTF8:)
- use the new name `String(validatingCString:)`
2023-09-11 14:17:05 -07:00
Max Desiatov
fc1043ec3b StdlibUnittest: fix building with WASI (#67394)
This file can now be built for WASI when `WASILibc` is imported. Only slight branching is needed to disable child process spawning for this platform.
2023-07-19 18:51:40 +01:00
Max Desiatov
21a2b78801 stdlib/benchmark: add canImport(Musl) where needed (#67120)
This allows compiling stdlib and benchmarks when targeting musl instead of Glibc.
2023-07-05 19:55:08 +01:00
Doug Gregor
8b4fe6be18 Eliminate some unnecessary shadowing generic parameters 2023-05-17 11:04:11 -07:00
Guillaume Lessard
1cd2c5fba0 [stdlib] remove incorrect uses of pointer conversion 2022-04-01 12:10:16 -06:00
Karoy Lorentey
7ce8544610 [StdlibUnittest] expectEqual: Use less opinionated argument names
Based on its argument names and messages, `expectEqual` and friends expects the expected value of the calculation being tested to be provided as its first argument, and the actual value as the second:

```
expectEqual(4, 2 + 2)
```

This does not always match actual use -- folks like myself find the opposite ordering far more natural:

```
expectEqual(2 + 2, 4)
```

`expectEqual` currently uses the `expected`/`actual` terminology in its failure messages, causing confusion and needless suffering.

Change `expectEqual`'s declaration and error messages to use a naming scheme that does not assume specific roles for the two arguments. (Namely, use `first`/`second` instead of `expected`/`actual`.)

An alternative way to solve this would be to use argument labels, as in `expectEqual(expected: 4, actual: 2 + 2)`, or to introduce some sort of expression builder scheme such as `expect(2 + 2).toEqual(2)`. These seem needlessly fussy and overly clever, respectively.
2022-02-16 14:00:54 -08:00
Karoy Lorentey
47956908b7 [Concurrency] SwiftStdlib 5.5 ⟹ SwiftStdlib 5.1 (usages)
The concurrency runtime now deploys back to macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, which corresponds to the 5.1 release of the stdlib.

Adjust macro usages accordingly.
2021-10-28 14:36:36 -07:00
Max Desiatov
cd90d849df StdlibUnittest: import _Concurrency explicitly (#39175)
StdlibUnittest is built with `-disable-implicit-concurrency-module-import`
and it uses concurrency feature. Therefore, without explicit import,
StdlibUnittest.swiftmodule doesn't have `IMPORTED_MODULE` entry of
`_Concurrency`. And it results link-failure when static linking because
swift_Concurrency is not linked.

Co-authored-by: Yuta Saito <kateinoigakukun@gmail.com>
2021-09-07 20:41:22 +01:00
Doug Gregor
e2d97af4bf Add availability gating for async function and actor type definitions.
Implements rdar://80098709.
2021-07-20 11:28:23 -07:00
Saleem Abdulrasool
7da9f8c02d StdlibUnittest: repair in-process concurrency test execution
The support for running concurrency tests individually with filters
invoked the non-concurrent supporting `runOneTest` accidentally. Fix
this to us the `runOneTestAsync` allowing the single async test to be
run in process again.  This is needed for ease of debugging (and in the
case of Windows, the only option for debugging).
2021-06-03 20:41:40 -07:00
David Zarzycki
654234ad64 [Testing] Unbreak minimal Swift builds
For various reasons, it can be useful/interesting to create builds of
Swift that minimize dependencies. Let's try to keep that working as long
as we can.
2021-04-16 17:39:01 -04:00
Evan Wilde
1d06521f32 Plumb async-ness through StdlibUnittest
This patch plumbs through the ability to run async code in the standard
library unittests. The async start-point is `runAllTestsAsync` and must
be called from an async context. For now, that means calling through
async-main.
2021-04-14 15:04:56 -07:00
Robert Widmann
f9a5c29bca [NFC] Fixup StdlibUnittest to Use Member Operators for Equatable and Comparable 2021-03-09 15:08:46 -08:00
Kuba (Brecka) Mracek
d7dfa3e942 Bring up tests + validation tests for the 'freestanding' build and the standalone_minimal preset (#34386) 2020-10-26 16:32:36 -07:00
Saleem Abdulrasool
2fc5cbdc14 stdlib: remove swiftMSVCRT, replace with swiftCRT on Windows
This replaces swiftMSVCRT with swiftCRT.  The big difference here is
that the `visualc` module is no longer imported nor exported.  The
`visualc` module remains in use for a singular test wrt availability,
but this should effectively remove the need for the `visualc` module.

The difference between the MSVCRT and ucrt module was not well
understood by most.  MSVCRT provided ucrt AND visualc, combining pieces
of the old MSVCRT and the newer ucrt.  The ucrt module is what you
really wanted most of the time, however, would need to use MSVCRT for
the convenience aliases for type-generic math and the deprecated math
constants.

Unfortunately, we cannot shadow the `ucrt` module and create a Swift SDK
overlay for ucrt as that seems to result in circular dependencies when
processing the `_Concurrency` module.

Although this makes using the C library easier for most people, it has a
more important subtle change: it cleaves the dependency on visualc.
This means that this enables use of Swift without Visual Studio for the
singular purpose of providing 3 header files.  Additionally, it removes
the need for the installation of 2 of the 4 support files.  This greatly
simplifies the deployment process on Windows.
2020-10-15 16:02:01 -07:00
Robert Widmann
cddf73ecdb [Gardening] Clean Up OS-Test Patterns Across The Codebase
Clean up a few general patterns that are now obviated by canImport

This aligns more generally with the cleanup that the Swift Package
Manager has already done in their automated XCTest-plumbing tool in
apple/swift-package-manager#1826.
2020-06-30 22:55:58 -07:00
Nate Chandler
8ec75d4933 [metadata prespecialization] Support classes with non-generic ancestors.
Previously, metadata prespecialization for classes only occurred when
all of a specialized generic class's ancestors were themselves generic.
Here, that requirement is lifted so that generic classes with concrete
ancestors are also eligible for prespecialization.
2020-06-08 14:57:50 -07:00
Ben Rimmington
f2c952cb69 [stdlib] Remove more unneeded numericCasts 2020-05-10 12:31:55 +01:00
3405691582
5847726f51 Preliminary support for OpenBSD in the stdlib.
These should hopefully all be uncontroversial, minimal changes to deal
with progressing the build to completion on OpenBSD or addressing minor
portability issues. This is not the full set of changes to get a
successful build; other portability issues will be addressed in future
commits.

Most of this is just adding the relevant clauses to the ifdefs, but of
note in this commit:

* StdlibUnittest.swift: the default conditional in _getOSVersion assumes
  an Apple platform, therefore the explicit conditional and the relevant
  enums need filling out. The default conditional should be #error, but
  we'll fix this in a different commit.

* tgmath.swift.gyb: inexplicably, OpenBSD is missing just lgammal_r.
  Tests are updated correspondingly.

* ThreadLocalStorage.h: we use the pthread implementation, so it
  seems we should typedef __swift_thread_key_t as pthread_key_t.
  However, that's also a tweak for another commit.
2020-03-01 12:50:06 -05:00
Max Desiatov
67297904ac [WebAssembly] Add ifdefs for the WASI target 2020-02-08 07:37:10 +00:00
Karoy Lorentey
d5ea371eed [test] Add some high-level tests for AutoreleasingUnsafeMutablePointer 2019-08-26 20:09:53 -07:00
Saleem Abdulrasool
1d1c362aba StdlibUnittest: consume the carriage return on stdout
This was already being done for the stderr, but not for stdout.  Doing
this means that we no longer get spurious carriage returns on the stdout
output stream on Windows.  This is needed for supporting the
validation test suite on Windows.
2019-06-05 13:59:22 -07:00
Mishal Shah
6c69c8d0bb Merge pull request #25135 from porglezomp-misc/fix/stdlib-unittest-over-release
FIx an overrelease in StdlibUnittest's getSystemVersionPlistProperty
2019-06-03 13:35:04 -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
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
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
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
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
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
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
Maxim Moiseev
ebf90f78be Make an StdlibUnitTest error message a bit more useful 2018-12-06 14:11:57 -08:00
Saleem Abdulrasool
0693bec1f1 sdlib: rename SwiftPrivatePthreadExtras to SwiftPrivateThreadExtras
This is in preparation to make the code here more target agnostic for
porting to the Windows threading primitives.  This is used pretty
extensively in the tests, so disabling tests would lose a chunk of
coverage.
2018-11-26 13:09:31 -08:00
Ben Cohen
df2307e035 [stdlib][DNM] Collapse sequence and collection wrappers (#20221)
* Concretize dropFirst/Last/sufix/prefix from Sequence

Remove split customization point

Eliminate SubSequence from Sequence protocol

Collapse LazyCollection

Collapse LazyMapCollection

Eliminate _SequenceWrapper

Collapse LazyFilterCollection

Collapse LazyDrop/PrefixWhileCollection

Fix tests, ABI stability update

Collapse FlattenSequence

* Add entries to source/ABI compatible expected results.

* Update tests to avoid pre-10.14 objc runtime bug

* Expunge _preprocessingPass
2018-11-14 10:05:58 -08:00