File tree 2 files changed +88
-0
lines changed
Sources/_InternalTestSupport
Tests/_InternalTestSupportTests
2 files changed +88
-0
lines changed Original file line number Diff line number Diff line change
1
+
2
+
3
+ //===----------------------------------------------------------------------===//
4
+ //
5
+ // This source file is part of the Swift open source project
6
+ //
7
+ // Copyright (c) 2024 Apple Inc. and the Swift project authors
8
+ // Licensed under Apache License v2.0 with Runtime Library Exception
9
+ //
10
+ // See http://swift.org/LICENSE.txt for license information
11
+ // See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
12
+ //
13
+ //===----------------------------------------------------------------------===//
14
+ import Basics
15
+
16
+ import Testing
17
+
18
+ public func isWindows( ) -> Bool {
19
+ #if os(Windows)
20
+ return true
21
+ #else
22
+ return false
23
+ #endif
24
+ }
25
+
26
+ public func isLinux( ) -> Bool {
27
+ #if os(Linux)
28
+ return true
29
+ #else
30
+ return false
31
+ #endif
32
+ }
33
+
34
+ public func isMacOS( ) -> Bool {
35
+ #if os(macOS)
36
+ return true
37
+ #else
38
+ return false
39
+ #endif
40
+ }
41
+
42
+ public func isRealSigningIdentityTestEnabled( ) -> Bool {
43
+ #if ENABLE_REAL_SIGNING_IDENTITY_TEST
44
+ return true
45
+ #else
46
+ return false
47
+ #endif
48
+ }
49
+
50
+ public func isEnvironmentVariableSet( _ variableName: EnvironmentKey ) -> Bool {
51
+ guard let value = Environment . current [ variableName] else { return false }
52
+ return !value. isEmpty
53
+ }
Original file line number Diff line number Diff line change
1
+ //===----------------------------------------------------------------------===//
2
+ //
3
+ // This source file is part of the Swift open source project
4
+ //
5
+ // Copyright (c) 2024 Apple Inc. and the Swift project authors
6
+ // Licensed under Apache License v2.0 with Runtime Library Exception
7
+ //
8
+ // See http://swift.org/LICENSE.txt for license information
9
+ // See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10
+ //
11
+ //===----------------------------------------------------------------------===//
12
+
13
+ import _InternalTestSupport
14
+ import Basics
15
+ import Testing
16
+
17
+ struct testisEnvironmentVariableSet {
18
+ @Test (
19
+ arguments: [
20
+ ( name: " " , expected: false ) ,
21
+ ( name: " DOES_NOT_EXIST " , expected: false ) ,
22
+ ( name: " HOME " , expected: true )
23
+ ]
24
+ )
25
+ func testisEnvironmentVariableSetReturnsExpectedValue( name: String , expected: Bool ) {
26
+ // GIVEN we have an environment variable name
27
+ let variableName = EnvironmentKey ( name)
28
+
29
+ // WHEN we call isEnvironmentVariableSet(varaiblename)
30
+ let actual = isEnvironmentVariableSet ( variableName)
31
+
32
+ // THEN we expect to return true
33
+ #expect( actual == expected, " Actual is not as expected " )
34
+ }
35
+ }
You can’t perform that action at this time.
0 commit comments