Skip to content

Commit d307e31

Browse files
committed
Merge pull request #2101 from harlanhaskins/stdlibunittest-interpreter-skip-crashes
[StdlibUnittest] Allow Interpreter to Expect Crashes
2 parents 9418718 + 5d88887 commit d307e31

21 files changed

+23
-30
lines changed

stdlib/private/StdlibUnittest/StdlibUnittest.swift.gyb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,14 @@ func _stdlib_getline() -> String? {
432432

433433
func _printDebuggingAdvice(_ fullTestName: String) {
434434
print("To debug, run:")
435-
print("$ \(Process.arguments[0]) " +
435+
var invocation = [Process.arguments[0]]
436+
let interpreter = getenv("SWIFT_INTERPRETER")
437+
if interpreter != nil {
438+
if let interpreterCmd = String(validatingUTF8: interpreter) {
439+
invocation.insert(interpreterCmd, at: 0)
440+
}
441+
}
442+
print("$ \(invocation.joined(separator: " ")) " +
436443
"--stdlib-unittest-in-process --stdlib-unittest-filter \"\(fullTestName)\"")
437444
}
438445

stdlib/private/SwiftPrivateLibcExtras/Subprocess.swift

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,17 @@ public func spawnChild(_ args: [String])
109109
}
110110

111111
var pid: pid_t = -1
112-
let spawnResult = withArrayOfCStrings([ Process.arguments[0] ] as Array + args) {
112+
var childArgs = args
113+
childArgs.insert(Process.arguments[0], at: 0)
114+
let interpreter = getenv("SWIFT_INTERPRETER")
115+
if interpreter != nil {
116+
if let invocation = String(validatingUTF8: interpreter) {
117+
childArgs.insert(invocation, at: 0)
118+
}
119+
}
120+
let spawnResult = withArrayOfCStrings(childArgs) {
113121
swift_posix_spawn(
114-
&pid, Process.arguments[0], &fileActions, nil, $0, _getEnviron())
122+
&pid, childArgs[0], &fileActions, nil, $0, _getEnviron())
115123
}
116124
if spawnResult != 0 {
117125
print(String(cString: strerror(spawnResult)))

test/1_stdlib/BridgeNonVerbatim.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
// RUN: %target-run-stdlib-swift %s | FileCheck %s
2020
// REQUIRES: executable_test
2121
//
22-
// XFAIL: interpret
2322
// REQUIRES: objc_interop
2423

2524
import Swift

test/1_stdlib/Bridgeable.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// RUN: %target-run-simple-swift | FileCheck %s
22
// REQUIRES: executable_test
33

4-
// XFAIL: interpret
54
// REQUIRES: objc_interop
65

76
// FIXME: Should go into the standard library.

test/1_stdlib/Builtins.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
// RUN: %target-run %t/Builtins
1616
// REQUIRES: executable_test
1717

18-
// XFAIL: interpret
19-
2018
import Swift
2119
import SwiftShims
2220
import StdlibUnittest

test/1_stdlib/Character.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// RUN: %target-run-stdlib-swift
22
// REQUIRES: executable_test
33

4-
// XFAIL: interpret
5-
64
import StdlibUnittest
75
import Swift
86
import SwiftPrivate

test/1_stdlib/FloatingPoint.swift.gyb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
// RUN: %S/../../utils/line-directive %t/FloatingPoint.swift -- %target-run %t/a.out
44
// REQUIRES: executable_test
55

6-
// XFAIL: interpret
7-
86
import Swift
97
import StdlibUnittest
108

test/1_stdlib/InputStream.swift.gyb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
// RUN: %S/../../utils/line-directive %t/InputStream.swift -- %target-run %t/a.out
1717
// REQUIRES: executable_test
1818

19-
// XFAIL: interpret
20-
2119
import StdlibUnittest
2220

2321

test/1_stdlib/Interval.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
// RUN: %target-run-simple-swift
1313
// REQUIRES: executable_test
1414
//
15-
// XFAIL: interpret
1615

1716
import StdlibUnittest
1817

test/1_stdlib/NSValueBridging.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
// RUN: %target-run-simple-swift
1313
// REQUIRES: executable_test
1414
//
15-
// XFAIL: interpret
1615
// REQUIRES: objc_interop
1716

1817
import StdlibUnittest

test/1_stdlib/Range.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// RUN: %target-run-simple-swift
22
// REQUIRES: executable_test
33

4-
// XFAIL: interpret
5-
64
import StdlibUnittest
75

86

test/1_stdlib/Strideable.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
// RUN: %target-run-simple-swift
1313
// REQUIRES: executable_test
1414
//
15-
// XFAIL: interpret
1615

1716
import StdlibUnittest
1817

test/1_stdlib/Unmanaged.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// RUN: %target-run-simple-swift
22
// REQUIRES: executable_test
33

4-
// XFAIL: interpret
5-
64
import StdlibUnittest
75

86

test/Interpreter/FunctionConversion.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
// REQUIRES: executable_test
1414
// REQUIRES: rdar24874073
1515
//
16-
// XFAIL: interpret
1716

1817
import StdlibUnittest
1918

test/Interpreter/SDK/CoreGraphics_CGFloat.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// REQUIRES: executable_test
33

44
// REQUIRES: objc_interop
5-
// XFAIL: interpret
65

76
import CoreGraphics
87
import Foundation

test/Interpreter/SDK/Foundation_printing.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// RUN: %target-run-simple-swift
22
// REQUIRES: executable_test
33

4-
// XFAIL: interpret
54
// REQUIRES: objc_interop
65

76
import Foundation

test/Interpreter/SDK/Foundation_test.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// RUN: %target-run-simple-swift
22
// REQUIRES: executable_test
33

4-
// XFAIL: interpret
54
// REQUIRES: objc_interop
65

76
import Foundation

test/Interpreter/SDK/autorelease.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
// optimization on i386, even in the iOS simulator.
88
// XFAIL: CPU=i386
99

10-
// XFAIL: interpret
11-
1210
import Foundation
1311

1412
class PrintOnDeinit: NSObject {

test/Interpreter/imported_objc_generics.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
// RUN: %target-run %t/a.out
77

88
// REQUIRES: executable_test
9-
// XFAIL: interpret
109
// REQUIRES: objc_interop
1110

1211
import Foundation

test/Interpreter/objc_class_properties.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
// RUN: %target-run %t/a.out
66

77
// REQUIRES: executable_test
8-
// XFAIL: interpret
98
// REQUIRES: objc_interop
109

1110
import Foundation

test/lit.cfg

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -613,14 +613,16 @@ if run_vendor == 'apple':
613613

614614
if 'interpret' in lit_config.params:
615615
target_run_base = (
616-
xcrun_prefix + '%s %s -module-name main %s %s'
617-
% (config.swift, target_options, config.swift_test_options,
616+
'%s %s %s -module-name main %s %s'
617+
% (xcrun_prefix, config.swift, target_options,
618+
config.swift_test_options,
618619
swift_execution_tests_extra_flags))
619620
config.target_run_simple_swift = (
620621
"%s %%s" % (target_run_base))
621622
config.target_run_stdlib_swift = (
622623
"%s -Xfrontend -disable-access-control %%s" % (target_run_base))
623624
config.available_features.add('interpret')
625+
config.environment['SWIFT_INTERPRETER'] = config.swift
624626

625627
(sw_vers_name, sw_vers_vers, sw_vers_build) = \
626628
darwin_get_sw_vers()
@@ -699,6 +701,7 @@ elif run_os == 'linux-gnu' or run_os == 'linux-gnueabihf' or run_os == 'freebsd'
699701
config.target_run_stdlib_swift = (
700702
'%s -Xfrontend -disable-access-control %%s' % (target_run_base))
701703
config.available_features.add('interpret')
704+
config.environment['SWIFT_INTERPRETER'] = config.swift
702705
config.target_sil_opt = (
703706
'%s -target %s %s %s' %
704707
(config.sil_opt, config.variant_triple, resource_dir_opt, mcp_opt))

0 commit comments

Comments
 (0)