Skip to content

[StdlibUnittest] Allow Interpreter to Expect Crashes #2101

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion stdlib/private/StdlibUnittest/StdlibUnittest.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,14 @@ func _stdlib_getline() -> String? {

func _printDebuggingAdvice(_ fullTestName: String) {
print("To debug, run:")
print("$ \(Process.arguments[0]) " +
var invocation = [Process.arguments[0]]
let interpreter = getenv("SWIFT_INTERPRETER")
if interpreter != nil {
if let interpreterCmd = String(validatingUTF8: interpreter) {
invocation.insert(interpreterCmd, at: 0)
}
}
print("$ \(invocation.joined(separator: " ")) " +
"--stdlib-unittest-in-process --stdlib-unittest-filter \"\(fullTestName)\"")
}

Expand Down
12 changes: 10 additions & 2 deletions stdlib/private/SwiftPrivateLibcExtras/Subprocess.swift
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,17 @@ public func spawnChild(_ args: [String])
}

var pid: pid_t = -1
let spawnResult = withArrayOfCStrings([ Process.arguments[0] ] as Array + args) {
var childArgs = args
childArgs.insert(Process.arguments[0], at: 0)
let interpreter = getenv("SWIFT_INTERPRETER")
if interpreter != nil {
if let invocation = String(validatingUTF8: interpreter) {
childArgs.insert(invocation, at: 0)
}
}
let spawnResult = withArrayOfCStrings(childArgs) {
swift_posix_spawn(
&pid, Process.arguments[0], &fileActions, nil, $0, _getEnviron())
&pid, childArgs[0], &fileActions, nil, $0, _getEnviron())
}
if spawnResult != 0 {
print(String(cString: strerror(spawnResult)))
Expand Down
1 change: 0 additions & 1 deletion test/1_stdlib/BridgeNonVerbatim.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
// RUN: %target-run-stdlib-swift %s | FileCheck %s
// REQUIRES: executable_test
//
// XFAIL: interpret
// REQUIRES: objc_interop

import Swift
Expand Down
1 change: 0 additions & 1 deletion test/1_stdlib/Bridgeable.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// RUN: %target-run-simple-swift | FileCheck %s
// REQUIRES: executable_test

// XFAIL: interpret
// REQUIRES: objc_interop

// FIXME: Should go into the standard library.
Expand Down
2 changes: 0 additions & 2 deletions test/1_stdlib/Builtins.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
// RUN: %target-run %t/Builtins
// REQUIRES: executable_test

// XFAIL: interpret

import Swift
import SwiftShims
import StdlibUnittest
Expand Down
2 changes: 0 additions & 2 deletions test/1_stdlib/Character.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// RUN: %target-run-stdlib-swift
// REQUIRES: executable_test

// XFAIL: interpret

import StdlibUnittest
import Swift
import SwiftPrivate
Expand Down
2 changes: 0 additions & 2 deletions test/1_stdlib/FloatingPoint.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
// RUN: %S/../../utils/line-directive %t/FloatingPoint.swift -- %target-run %t/a.out
// REQUIRES: executable_test

// XFAIL: interpret

import Swift
import StdlibUnittest

Expand Down
2 changes: 0 additions & 2 deletions test/1_stdlib/InputStream.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
// RUN: %S/../../utils/line-directive %t/InputStream.swift -- %target-run %t/a.out
// REQUIRES: executable_test

// XFAIL: interpret

import StdlibUnittest


Expand Down
1 change: 0 additions & 1 deletion test/1_stdlib/Interval.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// RUN: %target-run-simple-swift
// REQUIRES: executable_test
//
// XFAIL: interpret

import StdlibUnittest

Expand Down
1 change: 0 additions & 1 deletion test/1_stdlib/NSValueBridging.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// RUN: %target-run-simple-swift
// REQUIRES: executable_test
//
// XFAIL: interpret
// REQUIRES: objc_interop

import StdlibUnittest
Expand Down
2 changes: 0 additions & 2 deletions test/1_stdlib/Range.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// RUN: %target-run-simple-swift
// REQUIRES: executable_test

// XFAIL: interpret

import StdlibUnittest


Expand Down
1 change: 0 additions & 1 deletion test/1_stdlib/Strideable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// RUN: %target-run-simple-swift
// REQUIRES: executable_test
//
// XFAIL: interpret

import StdlibUnittest

Expand Down
2 changes: 0 additions & 2 deletions test/1_stdlib/Unmanaged.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// RUN: %target-run-simple-swift
// REQUIRES: executable_test

// XFAIL: interpret

import StdlibUnittest


Expand Down
1 change: 0 additions & 1 deletion test/Interpreter/FunctionConversion.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
// REQUIRES: executable_test
// REQUIRES: rdar24874073
//
// XFAIL: interpret

import StdlibUnittest

Expand Down
1 change: 0 additions & 1 deletion test/Interpreter/SDK/CoreGraphics_CGFloat.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// REQUIRES: executable_test

// REQUIRES: objc_interop
// XFAIL: interpret

import CoreGraphics
import Foundation
Expand Down
1 change: 0 additions & 1 deletion test/Interpreter/SDK/Foundation_printing.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// RUN: %target-run-simple-swift
// REQUIRES: executable_test

// XFAIL: interpret
// REQUIRES: objc_interop

import Foundation
Expand Down
1 change: 0 additions & 1 deletion test/Interpreter/SDK/Foundation_test.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// RUN: %target-run-simple-swift
// REQUIRES: executable_test

// XFAIL: interpret
// REQUIRES: objc_interop

import Foundation
Expand Down
2 changes: 0 additions & 2 deletions test/Interpreter/SDK/autorelease.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
// optimization on i386, even in the iOS simulator.
// XFAIL: CPU=i386

// XFAIL: interpret

import Foundation

class PrintOnDeinit: NSObject {
Expand Down
1 change: 0 additions & 1 deletion test/Interpreter/imported_objc_generics.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
// RUN: %target-run %t/a.out

// REQUIRES: executable_test
// XFAIL: interpret
// REQUIRES: objc_interop

import Foundation
Expand Down
1 change: 0 additions & 1 deletion test/Interpreter/objc_class_properties.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
// RUN: %target-run %t/a.out

// REQUIRES: executable_test
// XFAIL: interpret
// REQUIRES: objc_interop

import Foundation
Expand Down
7 changes: 5 additions & 2 deletions test/lit.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -613,14 +613,16 @@ if run_vendor == 'apple':

if 'interpret' in lit_config.params:
target_run_base = (
xcrun_prefix + '%s %s -module-name main %s %s'
% (config.swift, target_options, config.swift_test_options,
'%s %s %s -module-name main %s %s'
% (xcrun_prefix, config.swift, target_options,
config.swift_test_options,
swift_execution_tests_extra_flags))
config.target_run_simple_swift = (
"%s %%s" % (target_run_base))
config.target_run_stdlib_swift = (
"%s -Xfrontend -disable-access-control %%s" % (target_run_base))
config.available_features.add('interpret')
config.environment['SWIFT_INTERPRETER'] = config.swift

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