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

Add known broken tests for import placement #2425

Merged
merged 2 commits into from
Dec 2, 2021

Conversation

nini-faroux
Copy link
Contributor

@nini-faroux nini-faroux commented Dec 1, 2021

Tests for known issues with import placement.

@@ -855,7 +855,18 @@ watchedFilesTests = testGroup "watched files"

insertImportTests :: TestTree
insertImportTests = testGroup "insert import"
[ checkImport "above comment at top of module" "CommentAtTop.hs" "CommentAtTop.expected.hs" "import Data.Monoid"
[ (`xfail` "known broken") (checkImport "module where keyword lower in file no exports" "WhereKeywordLowerInFileNoExports.hs" "WhereKeywordLowerInFileNoExports.expected.hs" "import Data.Int")
Copy link
Member

Choose a reason for hiding this comment

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

please could you use the expectFailBecause existing function, if possible with a short insight about why do you think it fail ("known broken" would be fine though)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I'll do that later today.

@jneira
Copy link
Member

jneira commented Dec 1, 2021

Many thanks for adding tests, they will help a lot in an eventual resolution

//cc @eddiemundo

Comment on lines +3 to +4
{-# OPTIONS_GHC -Wall,
OPTIONS_GHC -Wno-unrecognised-pragmas #-}
Copy link
Collaborator

Choose a reason for hiding this comment

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

The expected version of this test doesn't have the OPTIONS_GHC -Wno-unrecognized-pragmas line. I think the expected version of the test should have this line unless the test does more than add an import.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no you're right, that's updated now.

@eddiemundo
Copy link
Collaborator

I see what @nini-faroux was talking about on where to extract the "pre-decl" parser functionality since it's needed in both ghcide CodeAction.hs, and the pragmas plugin. I also need it in the hlint plugin.

Of the existing places I think putting it in its own module under ghcide/src/Development/IDE/Spans would be ok since Spans is vaguely related, but stuffing it into CodeAction.hs or in its own module in that folder seems ok too since it has random stuff in there.

I think I might extract that functionality into one of those places later today.

Comment on lines 858 to 859
[ expectFailBecause "'findPositionFromImportsOrModuleDecl' function adds import directly under line with module declaration, not accounting for case when 'where' keyword is placed on lower line"
(checkImport "module where keyword lower in file no exports" "WhereKeywordLowerInFileNoExports.hs" "WhereKeywordLowerInFileNoExports.expected.hs" "import Data.Int")
Copy link
Member

Choose a reason for hiding this comment

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

minor formatting thing, maybe the tests could be more legible if they are splitted in several lines, something like

  [ expectFailBecause 
      $  "'findPositionFromImportsOrModuleDecl' function adds import directly under line with module declaration, " 
      ++ "not accounting for case when 'where' keyword is placed on lower line"
    (checkImport 
      "module where keyword lower in file no exports" 
      "WhereKeywordLowerInFileNoExports.hs" 
      "WhereKeywordLowerInFileNoExports.expected.hs" 
      "import Data.Int")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that's true, they're updated now

Copy link
Member

@jneira jneira left a comment

Choose a reason for hiding this comment

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

many thanks again, I hope tests would help in an eventual resolution

@jneira jneira added the merge me Label to trigger pull request merge label Dec 2, 2021
@mergify mergify bot merged commit 2e59c60 into haskell:master Dec 2, 2021
drsooch pushed a commit to drsooch/haskell-language-server that referenced this pull request Dec 3, 2021
Co-authored-by: Javier Neira <atreyu.bbb@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge me Label to trigger pull request merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants