Skip to content

Introduce common code for Recorders in Plugin Tests #3347

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

Merged
merged 33 commits into from
Nov 28, 2022

Conversation

fendor
Copy link
Collaborator

@fendor fendor commented Nov 19, 2022

Plugin Tests need a recorder. Most plugin test-suite just set it to mempty, which, I think, will make it more difficult to debug test-failures.

Some plugin test-suites roll their own plugin initialisation code. This is fine, but makes the logging behaviour non-uniform.

Introduce the PluginTestDescriptor type definition.
Utility functions to create PluginTestDescriptor's mkPluginTestDescriptor and mkPluginTestDescriptor' which will help migrating plugins to the newer co-log style logger.

Comment on lines 266 to 267
-- The created recorder writes to stderr if any of the given environment variables
-- have been set to a value different to @0@.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not write to stderr unconditionally, as the default recorder for HLS does?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Lots of noise, makes it hard to tell what testcase failed, imo. However, thats also fine by me

Copy link
Collaborator

Choose a reason for hiding this comment

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

But this is already the status quo, and lsp-test silences it anyway, so I'm not sure what the difference is

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No it is not, the status quo is, we hide the stderr unless LSP_TEST_LOG_STDERR=1 is given, take a look at this example run with the loggers for HLS and the testsuite writing to stderr vs not writing to stderr: https://paste.tomsmeding.com/0UbJEowE

@michaelpj
Copy link
Collaborator

This requires a new sway of test-functions, as long as we have plugins that use the old hslogger functions.

Argh, I forgot we hadn't purged all of that yet >:(

Copy link
Collaborator

@michaelpj michaelpj left a comment

Choose a reason for hiding this comment

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

LGTM!

@michaelpj
Copy link
Collaborator

I think "always have a recorder" is a good default tbh, so 👍 for refactoring things to make that the main way.

@fendor fendor force-pushed the refactor/test-plugin-loggers branch from aa69bda to 24a81b2 Compare November 26, 2022 16:23
@fendor fendor force-pushed the refactor/test-plugin-loggers branch 2 times, most recently from d4d5ce1 to fe57732 Compare November 26, 2022 16:28
@fendor
Copy link
Collaborator Author

fendor commented Nov 26, 2022

Ready for review, each commit modifies a single plugin so code owners can review exactly the commit they need to.

For reviewers, the most important changes happen in hls-test-utils/src/Test/Hls.hs
Everything else ought to follow naturally from the changes in that module.

@fendor fendor force-pushed the refactor/test-plugin-loggers branch from fe57732 to 108baf6 Compare November 26, 2022 16:30
Every plugin should use the new functions. This way, we can guarantee
predictable logging behaviour for tests.
Most notably, we now have a single control point, for co-log style
logging, how to write logs to stderr, and how to write logs for server
and plugin at the same time.
@fendor fendor force-pushed the refactor/test-plugin-loggers branch from 108baf6 to 93d2587 Compare November 26, 2022 16:37
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.

Thank you for great refactoring! LGTM 👍

@fendor fendor force-pushed the refactor/test-plugin-loggers branch from 93d2587 to 1c4c1d1 Compare November 26, 2022 18:54
@fendor fendor requested a review from pepeiborra November 26, 2022 19:00
Copy link
Collaborator

@ozkutuk ozkutuk left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Collaborator

@kokobd kokobd left a comment

Choose a reason for hiding this comment

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

LGTM!

@fendor fendor added the merge me Label to trigger pull request merge label Nov 28, 2022
@mergify mergify bot merged commit aeb57a8 into haskell:master Nov 28, 2022
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.

8 participants