Skip to content

Add known broken tests for import placement#2425

Merged
mergify[bot] merged 2 commits into
haskell:masterfrom
nini-faroux:import-tests
Dec 2, 2021
Merged

Add known broken tests for import placement#2425
mergify[bot] merged 2 commits into
haskell:masterfrom
nini-faroux:import-tests

Conversation

@nini-faroux

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

Copy link
Copy Markdown
Contributor

Tests for known issues with import placement.

Comment thread ghcide/test/exe/Main.hs Outdated
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
Copy Markdown
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
Copy Markdown
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

jneira commented Dec 1, 2021

Copy link
Copy Markdown
Member

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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 thread ghcide/test/exe/Main.hs Outdated
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
Copy Markdown
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
Copy Markdown
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

@jneira jneira left a comment

Copy link
Copy Markdown
Member

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
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.

3 participants