Skip to content

Commit 096edf1

Browse files
authored
Merge pull request #34579 from rintaro/ide-test-batchcompletion-xfail
[CodeCompletion] Add XFAIL to swift-ide-test
2 parents e9cf2d8 + 65f3133 commit 096edf1

File tree

2 files changed

+32
-7
lines changed

2 files changed

+32
-7
lines changed

test/IDE/complete_type.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ func testTypeInTupleType6() {
407407
}
408408

409409
func testTypeInTupleType7() {
410-
var localVar: (a: b: #^TYPE_IN_TUPLE_TYPE_7?skip=FIXME^#
410+
var localVar: (a: b: #^TYPE_IN_TUPLE_TYPE_7?xfail=FIXME^#
411411
}
412412

413413
//===---

tools/swift-ide-test/swift-ide-test.cpp

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -923,6 +923,7 @@ struct CompletionTestToken {
923923
StringRef Name;
924924
SmallVector<StringRef, 1> CheckPrefixes;
925925
StringRef Skip;
926+
StringRef Xfail;
926927
Optional<bool> IncludeKeywords = None;
927928
Optional<bool> IncludeComments = None;
928929

@@ -1003,6 +1004,10 @@ struct CompletionTestToken {
10031004
Result.Skip = Value;
10041005
continue;
10051006
}
1007+
if (Key == "xfail") {
1008+
Result.Xfail = Value;
1009+
continue;
1010+
}
10061011
Error = "unknown option (" + Key.str() + ") for token";
10071012
return true;
10081013
}
@@ -1166,6 +1171,7 @@ static int doBatchCodeCompletion(const CompilerInvocation &InitInvok,
11661171

11671172
// Process tokens.
11681173
SmallVector<StringRef, 0> FailedTokens;
1174+
SmallVector<StringRef, 0> UPassTokens;
11691175
for (const auto &Token : CCTokens) {
11701176
if (!options::CodeCompletionToken.empty() &&
11711177
options::CodeCompletionToken != Token.Name)
@@ -1185,6 +1191,11 @@ static int doBatchCodeCompletion(const CompilerInvocation &InitInvok,
11851191
continue;
11861192
}
11871193

1194+
bool failureExpected = !Token.Xfail.empty();
1195+
if (failureExpected) {
1196+
llvm::errs() << "Xfail: " << Token.Xfail << "\n";
1197+
}
1198+
11881199
auto IncludeKeywords = CodeCompletionKeywords;
11891200
if (Token.IncludeKeywords)
11901201
IncludeKeywords = *Token.IncludeKeywords;
@@ -1291,23 +1302,37 @@ static int doBatchCodeCompletion(const CompilerInvocation &InitInvok,
12911302
}
12921303
}
12931304

1294-
if (isFileCheckFailed) {
1305+
if (isFileCheckFailed == failureExpected) {
1306+
// Success. The result may be huge. Remove the result if it's succeeded.
1307+
llvm::sys::fs::remove(resultFilename);
1308+
} else if (isFileCheckFailed) {
1309+
// Unexpectedly failed.
12951310
FailedTokens.push_back(Token.Name);
12961311
} else {
1297-
// The result may be huge. Remove the result if it's succeeded.
1298-
llvm::sys::fs::remove(resultFilename);
1312+
// Unexpectedly passed.
1313+
UPassTokens.push_back(Token.Name);
12991314
}
13001315
}
13011316

1317+
if (FailedTokens.empty() && UPassTokens.empty())
1318+
return 0;
1319+
1320+
llvm::errs() << "----\n";
13021321
if (!FailedTokens.empty()) {
1303-
llvm::errs() << "----\n";
13041322
llvm::errs() << "Unexpected failures: ";
13051323
llvm::interleave(
13061324
FailedTokens, [&](StringRef name) { llvm::errs() << name; },
13071325
[&]() { llvm::errs() << ", "; });
1326+
llvm::errs() << "\n";
13081327
}
1309-
1310-
return !FailedTokens.empty();
1328+
if (!UPassTokens.empty()) {
1329+
llvm::errs() << "Unexpected passes: ";
1330+
llvm::interleave(
1331+
UPassTokens, [&](StringRef name) { llvm::errs() << name; },
1332+
[&]() { llvm::errs() << ", "; });
1333+
llvm::errs() << "\n";
1334+
}
1335+
return 1;
13111336
}
13121337

13131338
static int doREPLCodeCompletion(const CompilerInvocation &InitInvok,

0 commit comments

Comments
 (0)