Skip to content

[CodeCompletion] Batch code completion test #28946

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

Conversation

rintaro
Copy link
Member

@rintaro rintaro commented Dec 25, 2019

Utilize fast completion (reusing CompilerInstance) in libIDE code completion tests.

  • Catch regressions in fast-completion
  • Reduce the test execution time (e.g. 32sec -> approx. 2sec for complete_types.swift)

Introduce -batch-code-completion mode. The typical usage is:

// RUN: %swift-ide-test -batch-code-completion \
// RUN:     -filecheck %raw-FileCheck \
// RUN:     -completion-output-dir %t \
// RUN:     -source-filename %s

This scans the source file for tokens (#^NAME^#), then performs code completion for each token in random order with reuseastcontext mode.

Options are:

  • -filecheck: FileCheck command path. Completion results are checked with this FileCheck
  • -completion-output-dir: Temporary file directory. Completion results are output with ${output dir}/complete-${token name}.result
  • -random-seed: By default, tokens are shuffled with random generated seed. Using -random-seed you can specify shuffle seed. This is convenient for reproducing order-dependent failures
  • -code-completion-token: You can specify a specific token name to test, but in batch-code-completion mode

Each token can have several options (e.g. #^NAME?check=GLOBAL;comments=true^#):

  • check: By default, the completion results are FileCheck -check-prefixes=ed with the token name. check can changes the check-prefix name. Also, you can specify multiple check to perform multiple FileChecks with different prefixes
  • keywords: equivalent to -code-completion-keywords
  • comments: equivalent to -code-completion-comments
  • skip: Tokens with skip are skipped

In this PR. Only migrate test/IDE/complete_type.swift. But I intend to migrate other test files in follow up PRs.

rdar://problem/16025703

@rintaro rintaro force-pushed the ide-completion-batchtest-rdar16025703 branch from 78a60c1 to d3d2a31 Compare December 25, 2019 03:54
@rintaro rintaro force-pushed the ide-completion-batchtest-rdar16025703 branch from d3d2a31 to d69cc9b Compare January 2, 2020 22:00
@rintaro rintaro force-pushed the ide-completion-batchtest-rdar16025703 branch from d69cc9b to 4b617e7 Compare January 23, 2020 08:23
@rintaro rintaro force-pushed the ide-completion-batchtest-rdar16025703 branch from 4b617e7 to 524342d Compare June 18, 2020 19:58
}

func testTypeInTupleType7() {
var localVar: (a: b: #^TYPE_IN_TUPLE_TYPE_7^#
var localVar: (a: b: #^TYPE_IN_TUPLE_TYPE_7?skip=FIXME^#
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was not checked. i.e. no RUN: line was there.

Comment on lines -1151 to +752
extension Task.Inner.#^UNBOUND_DOT^# {}
func testUnbound(x: Task.Inner.#^UNBOUND_DOT^#) {}
extension Task.Inner.#^UNBOUND_DOT_1?check=UNBOUND_DOT^# {}
func testUnbound(x: Task.Inner.#^UNBOUND_DOT_2?check=UNBOUND_DOT^#) {}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UNBOUND_DOT used to be duplicated.

@rintaro
Copy link
Member Author

rintaro commented Jun 18, 2020

@swift-ci Please smoke test

@rintaro rintaro marked this pull request as ready for review June 18, 2020 20:19
@rintaro rintaro requested review from akyrtzi and benlangmuir June 18, 2020 20:19
@rintaro rintaro force-pushed the ide-completion-batchtest-rdar16025703 branch from 524342d to 4f9202b Compare June 18, 2020 20:58
@rintaro
Copy link
Member Author

rintaro commented Jun 18, 2020

@swift-ci Please smoke test

Copy link
Contributor

@benlangmuir benlangmuir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really happy you're working on this. It will make a huge difference in test performance once we port all the big tests.

llvm::errs() << "Elapsed: " << elapsed.count() << " msec\n";
OS.flush();

if (OutputDir.empty()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was surprised that empty output dir implies skipping filecheck. Should we make it an error to have no output dir unless you also have --dont-filecheck ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not specifying '-completion-output-dir' is now error unless -skip-filecheck

Utilize fast-completion in swift-ide-test
@rintaro rintaro force-pushed the ide-completion-batchtest-rdar16025703 branch from 4f9202b to f99fa56 Compare June 18, 2020 23:26
@rintaro
Copy link
Member Author

rintaro commented Jun 19, 2020

@swift-ci Please smoke test

@rintaro
Copy link
Member Author

rintaro commented Jun 19, 2020

@rintaro rintaro merged commit 2f89469 into swiftlang:master Jun 19, 2020
@rintaro rintaro deleted the ide-completion-batchtest-rdar16025703 branch June 19, 2020 03:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants