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

Fix the Eval plugin sporadic exceptions #1345

Merged
merged 3 commits into from
Feb 12, 2021
Merged

Fix the Eval plugin sporadic exceptions #1345

merged 3 commits into from
Feb 12, 2021

Conversation

pepeiborra
Copy link
Collaborator

Hopefully this will get rid of the sporadic exceptions

I also took the chance to speed up the test suite a bit.

Someone else should build the PR locally and test that the Eval plugin still works and performs well /cc @tittoassini @konn

Copy link
Collaborator

@konn konn left a comment

Choose a reason for hiding this comment

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

I've tested this branch and master with direct cradle change cherry-picked, using the following (rather long) one-liner, repeating Haddock comment test until it fails:

i=0;stack build --silent --stack-yaml=stack-8.8.4.yaml && export HLS_TEST_EXE=$(stack --stack-yaml=stack-8.8.4.yaml exec -- which haskell-language-server) ;while (stack test haskell-language-server:test:func-test --ta "-p Haddock -j1" --silent); do i=$(expr $i + 1); echo "OK: ${i}"; done

In master, it fails after a few to 25 successful trials.
With the changes in this branch, however, it won't fail even after 100 trials. Great!

@tittoassini
Copy link
Contributor

tittoassini commented Feb 11, 2021

I am actually getting BadDependency errors on all tests with "cabal test func-test", e.g.:

haskell-lsp:Starting up server ...
2021-02-11 21:09:23.055126 [ThreadId 6] - ---> {"jsonrpc":"2.0","params":{"rootUri":"file:///Users/titto/workspace/haskell-language-server/plugins/hls-eval-plugin/test/testdata","processId":78096,"rootPath":"/Users/titto/workspace/haskell-language-server/plugins/hls-eval-plugin/test/testdata","capabilities":{"workspace":{"didChangeWatchedFiles":{"dynamicRegistration":true},"symbol":{"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]},"dynamicRegistration":true},"workspaceEdit":{"documentChanges":true},"didChangeConfiguration":{"dynamicRegistration":true},"applyEdit":true,"executeCommand":{"dynamicRegistration":true},"workspaceFolders":true,"configuration":true},"textDocument":{"completion":{"dynamicRegistration":true,"contextSupport":true,"completionItem":{"tagSupport":{"valueSet":[1]},"preselectSupport":true,"commitCharactersSupport":true,"snippetSupport":true,"deprecatedSupport":true,"documentationFormat":["plaintext","markdown"]},"completionItemKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]}},"documentHighlight":{"dynamicRegistration":true},"synchronization":{"dynamicRegistration":true,"willSave":true,"didSave":true,"willSaveWaitUntil":true},"definition":{"dynamicRegistration":true},"signatureHelp":{"dynamicRegistration":true,"signatureInformation":{"ocumentationFormat":["plaintext","markdown"]}},"references":{"dynamicRegistration":true},"rangeFormatting":{"dynamicRegistration":true},"codeAction":{"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}},"dynamicRegistration":true},"foldingRange":{"lineFoldingOnly":false,"dynamicRegistration":true},"onTypeFormatting":{"dynamicRegistration":true},"codeLens":{"dynamicRegistration":true},"documentSymbol":{"hierarchicalDocumentSymbolSupport":true,"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]},"dynamicRegistration":true},"colorProvider":{"dynamicRegistration":true},"documentLink":{"dynamicRegistration":true},"formatting":{"dynamicRegistration":true},"implementation":{"dynamicRegistration":true},"typeDefinition":{"dynamicRegistration":true},"publishDiagnostics":{"tagSupport":{"valueSet":[1,2]},"relatedInformation":true},"rename":{"prepareSupport":true,"dynamicRegistration":true},"hover":{"contentFormat":["plaintext","markdown"],"dynamicRegistration":true}}},"trace":"off"},"method":"initialize","id":0}
2021-02-11 21:09:23.057119 [ThreadId 6] - haskell-lsp:initializeRequestHandler: setting current dir to project root:/Users/titto/workspace/haskell-language-server/plugins/hls-eval-plugin/test/testdata
2021-02-11 21:09:23.087616 [ThreadId 40] -  was cancelled
2021-02-11 21:09:23.087601 [ThreadId 34] - finish: ModuleName.ghcSession (took 0.27s)
2021-02-11 21:09:23.087759 [ThreadId 38] - codeLens was cancelled
2021-02-11 21:09:23.087963 [ThreadId 36] - parsed was cancelled
2021-02-11 21:09:23.088419 [ThreadId 34] - finish: codeLens (took 0.28s)
2021-02-11 21:09:23.088719 [ThreadId 30] - Unexpected exception on request, please report!
Message: RequestMessage {_jsonrpc = "2.0", _id = IdInt 1, _method = TextDocumentCodeLens, _params = CodeLensParams {_textDocument = TextDocumentIdentifier {_uri = Uri {getUri = "file:///Users/titto/workspace/haskell-language-server/plugins/hls-eval-plugin/test/testdata/T1.hs"}}, _workDoneToken = Nothing}}
Exception: BadDependency "GhcSession"
2021-02-11 21:09:23.088967 [ThreadId 34] - LOOKUP UP PERSISTENT FOR: GetParsedModuleWithComments
2021-02-11 21:09:23.088955 [ThreadId 8] - <--2--{"jsonrpc":"2.0","params":{"uri":"file:///Users/titto/workspace/haskell-language-server/plugins/hls-eval-plugin/test/testdata/T1.hs","diagnostics":[{"severity":1,"range":{"start":{"line":0,"character":0},"end":{"line":1,"character":0}},"source":"cradle","message":"ghcide compiled by GHC 8.8 failed to load packages: <command line>: cannot satisfy -package QuickCheck\n    (use -v for more information). \nPlease ensure that ghcide is compiled with the same GHC installation as the project."}]},"method":"textDocument/publishDiagnostics"}
2021-02-11 21:09:23.089144 [ThreadId 34] - finish: parsed (took 0.00s)
2021-02-11 21:09:23.089268 [ThreadId 8] - <--2--{"error":{"code":-32603,"message":"BadDependency \"GhcSession\""},"jsonrpc":"2.0","id":1}

@pepeiborra
Copy link
Collaborator Author

I am actually getting BadDependency errors on all tests with "cabal test func-test", e.g.:

haskell-lsp:Starting up server ...
2021-02-11 21:09:23.055126 [ThreadId 6] - ---> {"jsonrpc":"2.0","params":{"rootUri":"file:///Users/titto/workspace/haskell-language-server/plugins/hls-eval-plugin/test/testdata","processId":78096,"rootPath":"/Users/titto/workspace/haskell-language-server/plugins/hls-eval-plugin/test/testdata","capabilities":{"workspace":{"didChangeWatchedFiles":{"dynamicRegistration":true},"symbol":{"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]},"dynamicRegistration":true},"workspaceEdit":{"documentChanges":true},"didChangeConfiguration":{"dynamicRegistration":true},"applyEdit":true,"executeCommand":{"dynamicRegistration":true},"workspaceFolders":true,"configuration":true},"textDocument":{"completion":{"dynamicRegistration":true,"contextSupport":true,"completionItem":{"tagSupport":{"valueSet":[1]},"preselectSupport":true,"commitCharactersSupport":true,"snippetSupport":true,"deprecatedSupport":true,"documentationFormat":["plaintext","markdown"]},"completionItemKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]}},"documentHighlight":{"dynamicRegistration":true},"synchronization":{"dynamicRegistration":true,"willSave":true,"didSave":true,"willSaveWaitUntil":true},"definition":{"dynamicRegistration":true},"signatureHelp":{"dynamicRegistration":true,"signatureInformation":{"ocumentationFormat":["plaintext","markdown"]}},"references":{"dynamicRegistration":true},"rangeFormatting":{"dynamicRegistration":true},"codeAction":{"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}},"dynamicRegistration":true},"foldingRange":{"lineFoldingOnly":false,"dynamicRegistration":true},"onTypeFormatting":{"dynamicRegistration":true},"codeLens":{"dynamicRegistration":true},"documentSymbol":{"hierarchicalDocumentSymbolSupport":true,"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]},"dynamicRegistration":true},"colorProvider":{"dynamicRegistration":true},"documentLink":{"dynamicRegistration":true},"formatting":{"dynamicRegistration":true},"implementation":{"dynamicRegistration":true},"typeDefinition":{"dynamicRegistration":true},"publishDiagnostics":{"tagSupport":{"valueSet":[1,2]},"relatedInformation":true},"rename":{"prepareSupport":true,"dynamicRegistration":true},"hover":{"contentFormat":["plaintext","markdown"],"dynamicRegistration":true}}},"trace":"off"},"method":"initialize","id":0}
2021-02-11 21:09:23.057119 [ThreadId 6] - haskell-lsp:initializeRequestHandler: setting current dir to project root:/Users/titto/workspace/haskell-language-server/plugins/hls-eval-plugin/test/testdata
2021-02-11 21:09:23.087616 [ThreadId 40] -  was cancelled
2021-02-11 21:09:23.087601 [ThreadId 34] - finish: ModuleName.ghcSession (took 0.27s)
2021-02-11 21:09:23.087759 [ThreadId 38] - codeLens was cancelled
2021-02-11 21:09:23.087963 [ThreadId 36] - parsed was cancelled
2021-02-11 21:09:23.088419 [ThreadId 34] - finish: codeLens (took 0.28s)
2021-02-11 21:09:23.088719 [ThreadId 30] - Unexpected exception on request, please report!
Message: RequestMessage {_jsonrpc = "2.0", _id = IdInt 1, _method = TextDocumentCodeLens, _params = CodeLensParams {_textDocument = TextDocumentIdentifier {_uri = Uri {getUri = "file:///Users/titto/workspace/haskell-language-server/plugins/hls-eval-plugin/test/testdata/T1.hs"}}, _workDoneToken = Nothing}}
Exception: BadDependency "GhcSession"
2021-02-11 21:09:23.088967 [ThreadId 34] - LOOKUP UP PERSISTENT FOR: GetParsedModuleWithComments
2021-02-11 21:09:23.088955 [ThreadId 8] - <--2--{"jsonrpc":"2.0","params":{"uri":"file:///Users/titto/workspace/haskell-language-server/plugins/hls-eval-plugin/test/testdata/T1.hs","diagnostics":[{"severity":1,"range":{"start":{"line":0,"character":0},"end":{"line":1,"character":0}},"source":"cradle","message":"ghcide compiled by GHC 8.8 failed to load packages: <command line>: cannot satisfy -package QuickCheck\n    (use -v for more information). \nPlease ensure that ghcide is compiled with the same GHC installation as the project."}]},"method":"textDocument/publishDiagnostics"}
2021-02-11 21:09:23.089144 [ThreadId 34] - finish: parsed (took 0.00s)
2021-02-11 21:09:23.089268 [ThreadId 8] - <--2--{"error":{"code":-32603,"message":"BadDependency \"GhcSession\""},"jsonrpc":"2.0","id":1}

Ignore that, I tried to remove the cabal/stack cradle in the test suite but forgot that QuickCheck is required. I've rolled that change back and CI can confirm.

More importantly, can someone actually use the plugin and confirm that it works?

@konn
Copy link
Collaborator

konn commented Feb 12, 2021

BadDependency errors

This once occurred in my environment. I discovered that this occurs when there is a difference of GHC versions between the global environment (determined from PATH) and that of GHC used to build the haskell-language-server executable being tested (given by HLS_TEST_EXE environmental variable).

More importantly, can someone actually use the plugin and confirm that it works?

I've just tested the current version of this branch. It seems that at least for predefined func-test inputs, Eval Plugin works just out of the box.

@tittoassini
Copy link
Contributor

Yup, now it works beautifully, high five @pepeiborra!

As @pepeiborra is bravely looking into the innards of ghcide, I wondered if he could also fix or at least figure out the origin of another major issue with evaluation: the inability to import a local module inside a test.

The test case is in TLocalImportInTest:

module TLocalImportInTest where

-- >>> import qualified Util
-- >>> Util.a
-- attempting to use module ‘fake_uid:Util’ (/Users/titto/workspace/haskell-language-server/plugins/hls-eval-plugin/test/testdata/Util.hs) which is not loaded

@pepeiborra pepeiborra merged commit b2ea71d into master Feb 12, 2021
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.

4 participants