[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).
This commit is contained in:
Daniel Rodríguez Troitiño
2019-02-06 10:51:55 -08:00
parent d57880eaf8
commit d08b46c47e
30 changed files with 186 additions and 108 deletions

View File

@@ -11,10 +11,12 @@
import Swift
import StdlibUnittest
#if os(Linux) || os(Android)
import Glibc
#elseif os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
import Darwin
#elseif os(Linux) || os(FreeBSD) || os(PS4) || os(Android) || os(Cygwin) || os(Haiku)
import Glibc
#else
#error("Unsupported platform")
#endif
var POSIXErrorCodeTestSuite = TestSuite("POSIXErrorCode")