Skip to content

[CodeCompletion] Add XFAIL to swift-ide-test #34579

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
Nov 5, 2020
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
2 changes: 1 addition & 1 deletion test/IDE/complete_type.swift
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ func testTypeInTupleType6() {
}

func testTypeInTupleType7() {
var localVar: (a: b: #^TYPE_IN_TUPLE_TYPE_7?skip=FIXME^#
var localVar: (a: b: #^TYPE_IN_TUPLE_TYPE_7?xfail=FIXME^#
}

//===---
Expand Down
37 changes: 31 additions & 6 deletions tools/swift-ide-test/swift-ide-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -923,6 +923,7 @@ struct CompletionTestToken {
StringRef Name;
SmallVector<StringRef, 1> CheckPrefixes;
StringRef Skip;
StringRef Xfail;
Optional<bool> IncludeKeywords = None;
Optional<bool> IncludeComments = None;

Expand Down Expand Up @@ -1003,6 +1004,10 @@ struct CompletionTestToken {
Result.Skip = Value;
continue;
}
if (Key == "xfail") {
Result.Xfail = Value;
continue;
}
Error = "unknown option (" + Key.str() + ") for token";
return true;
}
Expand Down Expand Up @@ -1166,6 +1171,7 @@ static int doBatchCodeCompletion(const CompilerInvocation &InitInvok,

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

bool failureExpected = !Token.Xfail.empty();
if (failureExpected) {
llvm::errs() << "Xfail: " << Token.Xfail << "\n";
}

auto IncludeKeywords = CodeCompletionKeywords;
if (Token.IncludeKeywords)
IncludeKeywords = *Token.IncludeKeywords;
Expand Down Expand Up @@ -1291,23 +1302,37 @@ static int doBatchCodeCompletion(const CompilerInvocation &InitInvok,
}
}

if (isFileCheckFailed) {
if (isFileCheckFailed == failureExpected) {
// Success. The result may be huge. Remove the result if it's succeeded.
llvm::sys::fs::remove(resultFilename);
} else if (isFileCheckFailed) {
// Unexpectedly failed.
FailedTokens.push_back(Token.Name);
} else {
// The result may be huge. Remove the result if it's succeeded.
llvm::sys::fs::remove(resultFilename);
// Unexpectedly passed.
UPassTokens.push_back(Token.Name);
}
}

if (FailedTokens.empty() && UPassTokens.empty())
return 0;

llvm::errs() << "----\n";
if (!FailedTokens.empty()) {
llvm::errs() << "----\n";
llvm::errs() << "Unexpected failures: ";
llvm::interleave(
FailedTokens, [&](StringRef name) { llvm::errs() << name; },
[&]() { llvm::errs() << ", "; });
llvm::errs() << "\n";
}

return !FailedTokens.empty();
if (!UPassTokens.empty()) {
llvm::errs() << "Unexpected passes: ";
llvm::interleave(
UPassTokens, [&](StringRef name) { llvm::errs() << name; },
[&]() { llvm::errs() << ", "; });
llvm::errs() << "\n";
}
return 1;
}

static int doREPLCodeCompletion(const CompilerInvocation &InitInvok,
Expand Down