lsp-test icon indicating copy to clipboard operation
lsp-test copied to clipboard

See log only on failure

Open astoff opened this issue 5 years ago • 3 comments
trafficstars

I see there are options in SessionConfig to enable logging of stderr or protocol messages. But I would like my test script to show these things only if

  • the server crashes, or
  • lsp-test is unable to decode the json response, or
  • an hspec test fails.

How can I do this?

This is probably a simple hspec-related question, but it would be good to explain this in the readme/examples, since this tool may attract the interest of other non-Haskellers.

astoff avatar Dec 18 '19 11:12 astoff

This is a good idea, I'm going to work on automatically printing the stderr and logs whenever an exception occurs inside Session

lukel97 avatar Dec 20 '19 01:12 lukel97

@astoff By the way, as of 0.9.0.0 you can run your tests with the LSP_TEST_LOG_STDERR and LSP_TEST_LOG_MESSAGES environment variables set to print the logs without having to change the config

lukel97 avatar Dec 20 '19 01:12 lukel97

I noticed this, and it's indeed handy. What led me to open this issue was the following situation.

I had a test that worked on my local machine but failed on the CI with a different OS. I couldn't find any way to discover what was going on other than modifying my CI configuration (namely, enabling one of the environment variables you mentioned) and then pushing that to a temporary branch on Github.

I could keep the logging permanently active on the CI, but this has other disadvantages (for instance, having both LSP_TEST_LOG_STDERR and ...MESSAGES active at the same time garbles the output).

astoff avatar Dec 20 '19 13:12 astoff