Skip to content

Commit 02633c3

Browse files
committed
Modify test to work correctly on simulator
`simctl spawn` does not propagate exit codes through, so we need the test to exit using `exit(0)`, not `fatalError()`.
1 parent 0b718b6 commit 02633c3

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

test/Interop/SwiftToCxx/functions/swift-functions-execution.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
// RUN: %empty-directory(%t)
22

3-
// RUN: %target-swift-frontend %S/swift-functions.swift -typecheck -module-name Functions -clang-header-expose-decls=all-public -emit-clang-header-path %t/functions.h
3+
// RUN: %target-swift-frontend %S/swift-functions.swift -typecheck -module-name Functions -clang-header-expose-decls=all-public -emit-clang-header-path %t/functions.h -cxx-interoperability-mode=upcoming-swift
44

55
// RUN: %target-interop-build-clangxx -c %s -I %t -o %t/swift-functions-execution.o -g
66
// RUN: %target-interop-build-swift %S/swift-functions.swift -o %t/swift-functions-execution -Xlinker %t/swift-functions-execution.o -module-name Functions -Xfrontend -entry-point-function-name -Xfrontend swiftMain -g
77

88
// RUN: %target-codesign %t/swift-functions-execution
9-
// RUN: not --crash %target-run %t/swift-functions-execution 2>&1 | %FileCheck %s
9+
// RUN: %target-run %t/swift-functions-execution 2>&1 | %FileCheck %s
1010

1111
// REQUIRES: executable_test
1212

@@ -24,14 +24,11 @@ int main() {
2424
assert(Functions::passTwoIntReturnIntNoArgLabel(1, 2) == 42);
2525
assert(Functions::passTwoIntReturnInt(1, 2) == 3);
2626
assert(Functions::passTwoIntReturnIntNoArgLabelParamName(1, 4) == 5);
27-
28-
fflush(NULL); // before fatalError() call
29-
3027
Functions::passVoidReturnNever();
31-
return 0;
28+
return 42;
3229
}
3330

3431
// CHECK: passVoidReturnVoid
3532
// CHECK-NEXT: passIntReturnVoid -1
3633
// CHECK-NEXT: passTwoIntReturnIntNoArgLabel
37-
// CHECK-NEXT: Functions/swift-functions.swift:{{[0-9]+}}: Fatal error: passVoidReturnNever
34+
// CHECK-NEXT: passVoidReturnNever

test/Interop/SwiftToCxx/functions/swift-functions.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
// RUN: %empty-directory(%t)
2-
// RUN: %target-swift-frontend %s -typecheck -module-name Functions -clang-header-expose-decls=all-public -emit-clang-header-path %t/functions.h
2+
// RUN: %target-swift-frontend %s -typecheck -module-name Functions -clang-header-expose-decls=all-public -emit-clang-header-path %t/functions.h -cxx-interoperability-mode=upcoming-swift
33
// RUN: %FileCheck %s < %t/functions.h
44

5+
import CxxStdlib
6+
57
// RUN: %check-interop-cxx-header-in-clang(%t/functions.h)
68

79
// CHECK-LABEL: namespace Functions SWIFT_PRIVATE_ATTR SWIFT_SYMBOL_MODULE("Functions") {
@@ -44,7 +46,11 @@ public func passTwoIntReturnIntNoArgLabelParamName(_ x2: CInt, _ y2: CInt) -> CI
4446
// CHECK: return _impl::$s9Functions016passTwoIntReturnD19NoArgLabelParamNameys5Int32VAD_ADtF(x2, y2);
4547
// CHECK: }
4648

47-
public func passVoidReturnNever() -> Never { fatalError("passVoidReturnNever") }
49+
public func passVoidReturnNever() -> Never {
50+
print("passVoidReturnNever")
51+
fflush(nil) // before exit() call
52+
exit(0)
53+
}
4854

4955
// CHECK-LABEL: SWIFT_INLINE_THUNK void passVoidReturnNever() noexcept SWIFT_SYMBOL("s:9Functions19passVoidReturnNevers0E0OyF") SWIFT_NORETURN {
5056
// CHECK-NOT: return

0 commit comments

Comments
 (0)