Skip to content

Commit 1d2d15a

Browse files
authored
Merge pull request #38857 from hamishknight/third-times-a-charm
[test] Re-enable convert_bool.swift
2 parents 926a59c + 95ba423 commit 1d2d15a

File tree

2 files changed

+26
-22
lines changed

2 files changed

+26
-22
lines changed

test/refactoring/ConvertAsync/convert_bool.swift

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// REQUIRES: rdar81128571
21
// REQUIRES: objc_interop
32
// REQUIRES: concurrency
43

@@ -14,47 +13,47 @@ func optionalBoolWithErr(completion: @escaping (String?, Bool?, Bool, Error?) ->
1413

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

17-
// 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
16+
// RUN: %refactor -convert-call-to-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 -I %S/Inputs -I %t -target %target-triple %clang-importer-sdk-nosource | %FileCheck -check-prefix=BOOL-WITH-ERR %s
1817
boolWithErr { b, err in
1918
if !b {
2019
fatalError("oh no \(err!)")
2120
}
2221
print("not err")
2322
}
2423

25-
// 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
24+
// RUN: %refactor -convert-call-to-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 -I %S/Inputs -I %t -target %target-triple %clang-importer-sdk-nosource | %FileCheck -check-prefix=BOOL-WITH-ERR %s
2625
boolWithErr { b, err in
2726
if b {
2827
fatalError("oh no \(err!)")
2928
}
3029
print("not err")
3130
}
3231

33-
// 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
32+
// RUN: %refactor -convert-call-to-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 -I %S/Inputs -I %t -target %target-triple %clang-importer-sdk-nosource | %FileCheck -check-prefix=BOOL-WITH-ERR %s
3433
boolWithErr { b, err in
3534
if !b && err != nil {
3635
fatalError("oh no \(err!)")
3736
}
3837
print("not err")
3938
}
4039

41-
// 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
40+
// RUN: %refactor -convert-call-to-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 -I %S/Inputs -I %t -target %target-triple %clang-importer-sdk-nosource | %FileCheck -check-prefix=BOOL-WITH-ERR %s
4241
boolWithErr { b, err in
4342
if b && err != nil {
4443
fatalError("oh no \(err!)")
4544
}
4645
print("not err")
4746
}
4847

49-
// 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
48+
// RUN: %refactor -convert-call-to-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 -I %S/Inputs -I %t -target %target-triple %clang-importer-sdk-nosource | %FileCheck -check-prefix=BOOL-WITH-ERR %s
5049
boolWithErr { b, err in
5150
if err != nil && b == false {
5251
fatalError("oh no \(err!)")
5352
}
5453
print("not err")
5554
}
5655

57-
// 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
56+
// RUN: %refactor -convert-call-to-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 -I %S/Inputs -I %t -target %target-triple %clang-importer-sdk-nosource | %FileCheck -check-prefix=BOOL-WITH-ERR %s
5857
boolWithErr { b, err in
5958
if b == true && err == nil {
6059
} else {
@@ -63,7 +62,7 @@ boolWithErr { b, err in
6362
print("not err")
6463
}
6564

66-
// 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
65+
// RUN: %refactor -convert-call-to-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 -I %S/Inputs -I %t -target %target-triple %clang-importer-sdk-nosource | %FileCheck -check-prefix=BOOL-WITH-ERR %s
6766
boolWithErr { b, err in
6867
if !b && err == nil {
6968
} else {
@@ -81,7 +80,7 @@ boolWithErr { b, err in
8180

8281
// These 3 should both generate the same refactoring.
8382

84-
// 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
83+
// RUN: %refactor -convert-call-to-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 -I %S/Inputs -I %t -target %target-triple %clang-importer-sdk-nosource | %FileCheck -check-prefix=BOOL-WITH-ERR2 %s
8584
boolWithErr { success, err in
8685
if success == true && err == nil {
8786
print("hi")
@@ -91,7 +90,7 @@ boolWithErr { success, err in
9190
print("not err")
9291
}
9392

94-
// 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
93+
// RUN: %refactor -convert-call-to-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 -I %S/Inputs -I %t -target %target-triple %clang-importer-sdk-nosource | %FileCheck -check-prefix=BOOL-WITH-ERR2 %s
9594
boolWithErr { success, err in
9695
if success && err == nil {
9796
print("hi")
@@ -101,7 +100,7 @@ boolWithErr { success, err in
101100
print("not err")
102101
}
103102

104-
// 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
103+
// RUN: %refactor -convert-call-to-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 -I %S/Inputs -I %t -target %target-triple %clang-importer-sdk-nosource | %FileCheck -check-prefix=BOOL-WITH-ERR2 %s
105104
boolWithErr { success, err in
106105
if err == nil {
107106
print("hi")
@@ -119,7 +118,7 @@ boolWithErr { success, err in
119118
// BOOL-WITH-ERR2-NEXT: fatalError("oh no \(err)")
120119
// BOOL-WITH-ERR2-NEXT: }
121120

122-
// 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
121+
// RUN: %refactor -convert-call-to-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 -I %S/Inputs -I %t -target %target-triple %clang-importer-sdk-nosource | %FileCheck -check-prefix=BOOL-WITH-ERR3 %s
123122
boolWithErr { failure, err in
124123
if failure {
125124
print("a \(err!)")
@@ -142,7 +141,7 @@ boolWithErr { failure, err in
142141
// BOOL-WITH-ERR3-NEXT: }
143142

144143
// Don't handle the below example as the force unwrap of err takes place under a different condition.
145-
// 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
144+
// RUN: %refactor -convert-call-to-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 -I %S/Inputs -I %t -target %target-triple %clang-importer-sdk-nosource | %FileCheck -check-prefix=BOOL-DONT-HANDLE %s
146145
boolWithErr { success, err in
147146
if !success {
148147
if err != nil {
@@ -166,7 +165,7 @@ boolWithErr { success, err in
166165
// BOOL-DONT-HANDLE-NEXT: }
167166
// BOOL-DONT-HANDLE-NEXT: print("not err")
168167

169-
// 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
168+
// RUN: %refactor -convert-call-to-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 -I %S/Inputs -I %t -target %target-triple %clang-importer-sdk-nosource | %FileCheck -check-prefix=BOOL-DONT-HANDLE2 %s
170169
boolWithErr { success, err in
171170
if !success {
172171
func doThings() {
@@ -219,7 +218,7 @@ boolWithErr { success, err in
219218
// BOOL-DONT-HANDLE2-NEXT: }
220219
// BOOL-DONT-HANDLE2-NEXT: print("not err")
221220

222-
// 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
221+
// RUN: %refactor -convert-call-to-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 -I %S/Inputs -I %t -target %target-triple %clang-importer-sdk-nosource | %FileCheck -check-prefix=BOOL-DONT-HANDLE3 %s
223222
boolWithErr { success, err in
224223
if !success {
225224
fatalError("oh no maybe \(String(describing: err))")
@@ -235,7 +234,7 @@ boolWithErr { success, err in
235234
// BOOL-DONT-HANDLE3-NEXT: }
236235
// BOOL-DONT-HANDLE3-NEXT: print("not err")
237236

238-
// 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
237+
// RUN: %refactor -convert-call-to-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 -I %S/Inputs -I %t -target %target-triple %clang-importer-sdk-nosource | %FileCheck -check-prefix=BOOL-DONT-HANDLE4 %s
239238
boolWithErr { failure, err in
240239
if failure {
241240
print("a")
@@ -258,7 +257,7 @@ boolWithErr { failure, err in
258257
// BOOL-DONT-HANDLE4-NEXT: print("c")
259258
// BOOL-DONT-HANDLE4-NEXT: }
260259

261-
// 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
260+
// RUN: %refactor -convert-call-to-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 -I %S/Inputs -I %t -target %target-triple %clang-importer-sdk-nosource | %FileCheck -check-prefix=BOOL-WITH-ERR-SILLY %s
262261
boolWithErr { success, err in
263262
if success == false && err == nil {
264263
print("ummm wat \(err!)")
@@ -274,7 +273,7 @@ boolWithErr { success, err in
274273
// BOOL-WITH-ERR-SILLY-NEXT: }
275274
// BOOL-WITH-ERR-SILLY-NEXT: print("not err")
276275

277-
// 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
276+
// RUN: %refactor -convert-call-to-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 -I %S/Inputs -I %t -target %target-triple %clang-importer-sdk-nosource | %FileCheck -check-prefix=BOOL-WITH-ERR-SILLY2 %s
278277
boolWithErr { success, err in
279278
if success {
280279
print("ummm wat \(err!)")
@@ -292,7 +291,7 @@ boolWithErr { success, err in
292291
// BOOL-WITH-ERR-SILLY2-NEXT: print("ummm wat \(<#err#>!)")
293292
// BOOL-WITH-ERR-SILLY2-NEXT: }
294293

295-
// 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
294+
// RUN: %refactor -convert-call-to-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 -I %S/Inputs -I %t -target %target-triple %clang-importer-sdk-nosource | %FileCheck -check-prefix=MULTI-BOOL-WITH-ERR %s
296295
multipleBoolWithErr { str, b1, b2, err in
297296
if !b1 && !b2 {
298297
print("a \(err!)")
@@ -328,7 +327,7 @@ multipleBoolWithErr { str, b1, b2, err in
328327
// MULTI-BOOL-WITH-ERR-NEXT: print("d \(err)")
329328
// MULTI-BOOL-WITH-ERR-NEXT: }
330329

331-
// 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
330+
// RUN: %refactor -convert-call-to-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 -I %S/Inputs -I %t -target %target-triple %clang-importer-sdk-nosource | %FileCheck -check-prefix=OPT-BOOL-WITH-ERR %s
332331
optionalBoolWithErr { str, optBool, b, err in
333332
if optBool != nil {
334333
print("a \(err!)")
@@ -373,7 +372,7 @@ optionalBoolWithErr { str, optBool, b, err in
373372
// OPT-BOOL-WITH-ERR-NEXT: print("g \(err)")
374373
// OPT-BOOL-WITH-ERR-NEXT: }
375374

376-
// 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
375+
// RUN: %refactor -convert-call-to-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 -I %S/Inputs -I %t -target %target-triple %clang-importer-sdk-nosource | %FileCheck -check-prefix=OBJC-BOOL-WITH-ERR %s
377376
ClassWithHandlerMethods.firstBoolFlagSuccess("") { str, success, unrelated, err in
378377
if !unrelated {
379378
print(err!)
@@ -404,7 +403,7 @@ ClassWithHandlerMethods.firstBoolFlagSuccess("") { str, success, unrelated, err
404403
// OBJC-BOOL-WITH-ERR-NEXT: print(err)
405404
// OBJC-BOOL-WITH-ERR-NEXT: }
406405

407-
// 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
406+
// RUN: %refactor -convert-call-to-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 -I %S/Inputs -I %t -target %target-triple %clang-importer-sdk-nosource | %FileCheck -check-prefix=OBJC-BOOL-WITH-ERR2 %s
408407
ClassWithHandlerMethods.secondBoolFlagFailure("") { str, unrelated, failure, err in
409408
if unrelated {
410409
print(err!)

tools/swift-refactor/swift-refactor.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,9 @@ static llvm::cl::list<std::string>
135135
ImportPaths("I",
136136
llvm::cl::desc("Add a directory to the import search path"));
137137

138+
static llvm::cl::opt<std::string>
139+
Triple("target", llvm::cl::desc("target triple"));
140+
138141
enum class DumpType {
139142
REWRITTEN,
140143
JSON,
@@ -288,6 +291,8 @@ int main(int argc, char *argv[]) {
288291

289292
Invocation.setSDKPath(options::SDK);
290293
Invocation.setImportSearchPaths(options::ImportPaths);
294+
if (!options::Triple.empty())
295+
Invocation.setTargetTriple(options::Triple);
291296

292297
Invocation.getFrontendOptions().InputsAndOutputs.addInputFile(
293298
options::SourceFilename);

0 commit comments

Comments
 (0)