Skip to content

[test] Re-enable convert_bool.swift #38130

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
merged 1 commit into from
Jun 29, 2021
Merged
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
50 changes: 22 additions & 28 deletions test/refactoring/ConvertAsync/convert_bool.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,7 @@
// REQUIRES: concurrency

// RUN: %empty-directory(%t)

// This test somehow depends on the Foundation overlay present in the build
// directory, even though it uses the mock SDK. Unfortunately we can't
// continue building overlays in-tree, so this will need further investigation.
// (The hidden dependency seems like a problem -- the mock SDK ought to use mock
// overlays, not the real ones.)
// REQUIRES: rdar78879483
// RUN: %build-clang-importer-objc-overlays

import Foundation
import ConvertBoolObjC
Expand All @@ -19,47 +13,47 @@ func optionalBoolWithErr(completion: (String?, Bool?, Bool, Error?) -> Void) {}

// All 7 of the below should generate the same refactoring.

// RUN: %refactor -convert-call-to-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 -I %S/Inputs -sdk %clang-importer-sdk-path | %FileCheck -check-prefix=BOOL-WITH-ERR %s
// RUN: %refactor -convert-call-to-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 -I %S/Inputs -I %t %clang-importer-sdk-nosource | %FileCheck -check-prefix=BOOL-WITH-ERR %s
boolWithErr { b, err in
if !b {
fatalError("oh no \(err!)")
}
print("not err")
}

// RUN: %refactor -convert-call-to-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 -I %S/Inputs -sdk %clang-importer-sdk-path | %FileCheck -check-prefix=BOOL-WITH-ERR %s
// RUN: %refactor -convert-call-to-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 -I %S/Inputs -I %t %clang-importer-sdk-nosource | %FileCheck -check-prefix=BOOL-WITH-ERR %s
boolWithErr { b, err in
if b {
fatalError("oh no \(err!)")
}
print("not err")
}

// RUN: %refactor -convert-call-to-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 -I %S/Inputs -sdk %clang-importer-sdk-path | %FileCheck -check-prefix=BOOL-WITH-ERR %s
// RUN: %refactor -convert-call-to-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 -I %S/Inputs -I %t %clang-importer-sdk-nosource | %FileCheck -check-prefix=BOOL-WITH-ERR %s
boolWithErr { b, err in
if !b && err != nil {
fatalError("oh no \(err!)")
}
print("not err")
}

// RUN: %refactor -convert-call-to-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 -I %S/Inputs -sdk %clang-importer-sdk-path | %FileCheck -check-prefix=BOOL-WITH-ERR %s
// RUN: %refactor -convert-call-to-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 -I %S/Inputs -I %t %clang-importer-sdk-nosource | %FileCheck -check-prefix=BOOL-WITH-ERR %s
boolWithErr { b, err in
if b && err != nil {
fatalError("oh no \(err!)")
}
print("not err")
}

// RUN: %refactor -convert-call-to-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 -I %S/Inputs -sdk %clang-importer-sdk-path | %FileCheck -check-prefix=BOOL-WITH-ERR %s
// RUN: %refactor -convert-call-to-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 -I %S/Inputs -I %t %clang-importer-sdk-nosource | %FileCheck -check-prefix=BOOL-WITH-ERR %s
boolWithErr { b, err in
if err != nil && b == false {
fatalError("oh no \(err!)")
}
print("not err")
}

// RUN: %refactor -convert-call-to-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 -I %S/Inputs -sdk %clang-importer-sdk-path | %FileCheck -check-prefix=BOOL-WITH-ERR %s
// RUN: %refactor -convert-call-to-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 -I %S/Inputs -I %t %clang-importer-sdk-nosource | %FileCheck -check-prefix=BOOL-WITH-ERR %s
boolWithErr { b, err in
if b == true && err == nil {
} else {
Expand All @@ -68,7 +62,7 @@ boolWithErr { b, err in
print("not err")
}

// RUN: %refactor -convert-call-to-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 -I %S/Inputs -sdk %clang-importer-sdk-path | %FileCheck -check-prefix=BOOL-WITH-ERR %s
// RUN: %refactor -convert-call-to-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 -I %S/Inputs -I %t %clang-importer-sdk-nosource | %FileCheck -check-prefix=BOOL-WITH-ERR %s
boolWithErr { b, err in
if !b && err == nil {
} else {
Expand All @@ -86,7 +80,7 @@ boolWithErr { b, err in

// These 3 should both generate the same refactoring.

// RUN: %refactor -convert-call-to-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 -I %S/Inputs -sdk %clang-importer-sdk-path | %FileCheck -check-prefix=BOOL-WITH-ERR2 %s
// RUN: %refactor -convert-call-to-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 -I %S/Inputs -I %t %clang-importer-sdk-nosource | %FileCheck -check-prefix=BOOL-WITH-ERR2 %s
boolWithErr { success, err in
if success == true && err == nil {
print("hi")
Expand All @@ -96,7 +90,7 @@ boolWithErr { success, err in
print("not err")
}

// RUN: %refactor -convert-call-to-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 -I %S/Inputs -sdk %clang-importer-sdk-path | %FileCheck -check-prefix=BOOL-WITH-ERR2 %s
// RUN: %refactor -convert-call-to-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 -I %S/Inputs -I %t %clang-importer-sdk-nosource | %FileCheck -check-prefix=BOOL-WITH-ERR2 %s
boolWithErr { success, err in
if success && err == nil {
print("hi")
Expand All @@ -106,7 +100,7 @@ boolWithErr { success, err in
print("not err")
}

// RUN: %refactor -convert-call-to-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 -I %S/Inputs -sdk %clang-importer-sdk-path | %FileCheck -check-prefix=BOOL-WITH-ERR2 %s
// RUN: %refactor -convert-call-to-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 -I %S/Inputs -I %t %clang-importer-sdk-nosource | %FileCheck -check-prefix=BOOL-WITH-ERR2 %s
boolWithErr { success, err in
if err == nil {
print("hi")
Expand All @@ -124,7 +118,7 @@ boolWithErr { success, err in
// BOOL-WITH-ERR2-NEXT: fatalError("oh no \(err)")
// BOOL-WITH-ERR2-NEXT: }

// RUN: %refactor -convert-call-to-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 -I %S/Inputs -sdk %clang-importer-sdk-path | %FileCheck -check-prefix=BOOL-WITH-ERR3 %s
// RUN: %refactor -convert-call-to-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 -I %S/Inputs -I %t %clang-importer-sdk-nosource | %FileCheck -check-prefix=BOOL-WITH-ERR3 %s
boolWithErr { failure, err in
if failure {
print("a \(err!)")
Expand All @@ -147,7 +141,7 @@ boolWithErr { failure, err in
// BOOL-WITH-ERR3-NEXT: }

// Don't handle the below example as the force unwrap of err takes place under a different condition.
// RUN: %refactor -convert-call-to-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 -I %S/Inputs -sdk %clang-importer-sdk-path | %FileCheck -check-prefix=BOOL-DONT-HANDLE %s
// RUN: %refactor -convert-call-to-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 -I %S/Inputs -I %t %clang-importer-sdk-nosource | %FileCheck -check-prefix=BOOL-DONT-HANDLE %s
boolWithErr { success, err in
if !success {
if err != nil {
Expand All @@ -171,7 +165,7 @@ boolWithErr { success, err in
// BOOL-DONT-HANDLE-NEXT: }
// BOOL-DONT-HANDLE-NEXT: print("not err")

// RUN: %refactor -convert-call-to-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 -I %S/Inputs -sdk %clang-importer-sdk-path | %FileCheck -check-prefix=BOOL-DONT-HANDLE2 %s
// RUN: %refactor -convert-call-to-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 -I %S/Inputs -I %t %clang-importer-sdk-nosource | %FileCheck -check-prefix=BOOL-DONT-HANDLE2 %s
boolWithErr { success, err in
if !success {
func doThings() {
Expand Down Expand Up @@ -224,7 +218,7 @@ boolWithErr { success, err in
// BOOL-DONT-HANDLE2-NEXT: }
// BOOL-DONT-HANDLE2-NEXT: print("not err")

// RUN: %refactor -convert-call-to-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 -I %S/Inputs -sdk %clang-importer-sdk-path | %FileCheck -check-prefix=BOOL-DONT-HANDLE3 %s
// RUN: %refactor -convert-call-to-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 -I %S/Inputs -I %t %clang-importer-sdk-nosource | %FileCheck -check-prefix=BOOL-DONT-HANDLE3 %s
boolWithErr { success, err in
if !success {
fatalError("oh no maybe \(err)")
Expand All @@ -240,7 +234,7 @@ boolWithErr { success, err in
// BOOL-DONT-HANDLE3-NEXT: }
// BOOL-DONT-HANDLE3-NEXT: print("not err")

// RUN: %refactor -convert-call-to-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 -I %S/Inputs -sdk %clang-importer-sdk-path | %FileCheck -check-prefix=BOOL-DONT-HANDLE4 %s
// RUN: %refactor -convert-call-to-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 -I %S/Inputs -I %t %clang-importer-sdk-nosource | %FileCheck -check-prefix=BOOL-DONT-HANDLE4 %s
boolWithErr { failure, err in
if failure {
print("a")
Expand All @@ -263,7 +257,7 @@ boolWithErr { failure, err in
// BOOL-DONT-HANDLE4-NEXT: print("c")
// BOOL-DONT-HANDLE4-NEXT: }

// RUN: %refactor -convert-call-to-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 -I %S/Inputs -sdk %clang-importer-sdk-path | %FileCheck -check-prefix=BOOL-WITH-ERR-SILLY %s
// RUN: %refactor -convert-call-to-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 -I %S/Inputs -I %t %clang-importer-sdk-nosource | %FileCheck -check-prefix=BOOL-WITH-ERR-SILLY %s
boolWithErr { success, err in
if success == false && err == nil {
print("ummm wat \(err!)")
Expand All @@ -279,7 +273,7 @@ boolWithErr { success, err in
// BOOL-WITH-ERR-SILLY-NEXT: }
// BOOL-WITH-ERR-SILLY-NEXT: print("not err")

// RUN: %refactor -convert-call-to-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 -I %S/Inputs -sdk %clang-importer-sdk-path | %FileCheck -check-prefix=BOOL-WITH-ERR-SILLY2 %s
// RUN: %refactor -convert-call-to-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 -I %S/Inputs -I %t %clang-importer-sdk-nosource | %FileCheck -check-prefix=BOOL-WITH-ERR-SILLY2 %s
boolWithErr { success, err in
if success {
print("ummm wat \(err!)")
Expand All @@ -297,7 +291,7 @@ boolWithErr { success, err in
// BOOL-WITH-ERR-SILLY2-NEXT: print("ummm wat \(<#err#>!)")
// BOOL-WITH-ERR-SILLY2-NEXT: }

// RUN: %refactor -convert-call-to-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 -I %S/Inputs -sdk %clang-importer-sdk-path | %FileCheck -check-prefix=MULTI-BOOL-WITH-ERR %s
// RUN: %refactor -convert-call-to-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 -I %S/Inputs -I %t %clang-importer-sdk-nosource | %FileCheck -check-prefix=MULTI-BOOL-WITH-ERR %s
multipleBoolWithErr { str, b1, b2, err in
if !b1 && !b2 {
print("a \(err!)")
Expand Down Expand Up @@ -333,7 +327,7 @@ multipleBoolWithErr { str, b1, b2, err in
// MULTI-BOOL-WITH-ERR-NEXT: print("d \(err)")
// MULTI-BOOL-WITH-ERR-NEXT: }

// RUN: %refactor -convert-call-to-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 -I %S/Inputs -sdk %clang-importer-sdk-path | %FileCheck -check-prefix=OPT-BOOL-WITH-ERR %s
// RUN: %refactor -convert-call-to-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 -I %S/Inputs -I %t %clang-importer-sdk-nosource | %FileCheck -check-prefix=OPT-BOOL-WITH-ERR %s
optionalBoolWithErr { str, optBool, b, err in
if optBool != nil {
print("a \(err!)")
Expand Down Expand Up @@ -378,7 +372,7 @@ optionalBoolWithErr { str, optBool, b, err in
// OPT-BOOL-WITH-ERR-NEXT: print("g \(err)")
// OPT-BOOL-WITH-ERR-NEXT: }

// RUN: %refactor -convert-call-to-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 -I %S/Inputs -sdk %clang-importer-sdk-path | %FileCheck -check-prefix=OBJC-BOOL-WITH-ERR %s
// RUN: %refactor -convert-call-to-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 -I %S/Inputs -I %t %clang-importer-sdk-nosource | %FileCheck -check-prefix=OBJC-BOOL-WITH-ERR %s
ClassWithHandlerMethods.firstBoolFlagSuccess("") { str, success, unrelated, err in
if !unrelated {
print(err!)
Expand Down Expand Up @@ -409,7 +403,7 @@ ClassWithHandlerMethods.firstBoolFlagSuccess("") { str, success, unrelated, err
// OBJC-BOOL-WITH-ERR-NEXT: print(err)
// OBJC-BOOL-WITH-ERR-NEXT: }

// RUN: %refactor -convert-call-to-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 -I %S/Inputs -sdk %clang-importer-sdk-path | %FileCheck -check-prefix=OBJC-BOOL-WITH-ERR2 %s
// RUN: %refactor -convert-call-to-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 -I %S/Inputs -I %t %clang-importer-sdk-nosource | %FileCheck -check-prefix=OBJC-BOOL-WITH-ERR2 %s
ClassWithHandlerMethods.secondBoolFlagFailure("") { str, unrelated, failure, err in
if unrelated {
print(err!)
Expand Down