Skip to content
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

Added the script that helps me fix dafny issues. #3038

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

MikaelMayer
Copy link
Member

@MikaelMayer MikaelMayer commented Nov 10, 2022

Update: Added integration tests for this script

To see examples of the script workflow, please have a look at the tests

This file makes it possible to fix an error in Dafny in no time.
Add the following alias in your bash profile:

alias fix='node scripts/fix-dafny-issue.js'

First usage

> fix [<issueNumber> [<issueKeyword>]]

This script will automate for you and ask questions as appropriate.

  • It asks you for the issue number and issue keyword if not provided
  • It fetches the reproducing code of the issue
  • It adds the test to the codebase
    • If it's a CI test, it creates Test/git-issues/git-issue-<issueNumber>.dfy
      and Test/git-issues/git-issue-<issueNumber>.dfy.expect
      ensuring it contains a header that LIT can parse, considering the possibility that it needs to be run
      Then, it opens these two files in their default editor.
    • If it's a language server tests, it adds the code as a first test to
      DafnyLanguageServer.Text/Synchronization/DiagnosticsTest.cs and
      creates commented placeholders for the interaction and expected results.
  • It creates a branch named fix-<issueNumber>-<issueKeyword>, and commits the files there immediately
  • It provides you with information to debug the issue in Rider, in CLI dotnet, or just run Dafny.

For an issue that already exists, then you enter the command fix alone,

  • It compiles and runs the tests (CI or Language Server, or both)
  • If all the tests pass, it asks you if you want to commit the changes.
    If you accept:
  • It creates the doc/dev/news/<issueNumber>.fix file for you the first time, asking you about its content
  • It adds all new and modified files
    (including other git-issue-<issueNumber><suffix>.dfy files)
  • It pushes the changes
  • If the first time it's pushed, it opens your browser with a page
    to create the PR with the title and description already populated.

If you want to switch to another issue that you already initiated,
ensure the working directory is clean, and run

> fix <existing issue number | pr number | keyword>

That will make the script to work:

  • It finds and checks out the branch matching the issue number, the PR number, or a keyword
  • It opens the test files in their respective editors (for CI tests only)
  • It rebuilds the solution
  • It provides you with information on how to test the issue.

If you are already in the issue branch and you want to re-open
the test files (because you closed them...), just write

> fix open

If you want to do the publishing without running the tests, just write

> fix force

If you want to add a new or existing test case for the same issue
(e.g. Test/git-issues/git-issue-b.dfy), run

> fix more <optional existing issue # or existing test name>

If you just write fix more, you will be prompted for the argument.

  • Providing a number will let you import another GitHub issue.
  • Providing an existing integration test name pattern will ensure that all these
    selected tests are run when you run fix without arguments.
    If more than one test is found, you'll be prompted to confirm your choices.

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.

None yet

1 participant