Logger refactoring#1302
Conversation
|
Some tests are failing due to circular dependency, I need to rethink some stuff around the logger. Changing this PR to draft for the time being. |
5fa3b61 to
2c53cfd
Compare
|
The circular dependency has been fixed, I still need to fix the unit tests but this should not impact anything else than the unit tests themselves. |
There was a problem hiding this comment.
Tested and it works as advertised. Note that even with this PR profile options (such as test_levels or logfilter) are still expected to use capitalized Test module names.
I have one suggestion: since module names in share/modules.txt are already in the format suggested by zonemaster/zonemaster#1200, for simplicity purposes we could already remove the forced upper-case module names in Engine where applicable. See the proposed change below to Zonemaster::Engine::Translator:
$ git log -1 --oneline
b96d62ea (HEAD -> test-PR1302) fix log filter
$ git diff
diff --git a/lib/Zonemaster/Engine/Translator.pm b/lib/Zonemaster/Engine/Translator.pm
index 42fef57f..23bdc726 100644
--- a/lib/Zonemaster/Engine/Translator.pm
+++ b/lib/Zonemaster/Engine/Translator.pm
@@ -174,10 +174,10 @@ sub _load_data {
sub _build_all_tag_descriptions {
my %all_tag_descriptions;
- $all_tag_descriptions{SYSTEM} = \%TAG_DESCRIPTIONS;
+ $all_tag_descriptions{System} = \%TAG_DESCRIPTIONS;
foreach my $mod ( 'Basic', Zonemaster::Engine->modules ) {
my $module = 'Zonemaster::Engine::Test::' . $mod;
- $all_tag_descriptions{ uc( $mod ) } = $module->tag_descriptions;
+ $all_tag_descriptions{ $mod } = $module->tag_descriptions;
}
return \%all_tag_descriptions;
@@ -231,7 +231,7 @@ sub to_string {
sub translate_tag {
my ( $self, $entry ) = @_;
- return $self->_translate_tag( uc $entry->module, $entry->tag, $entry->printable_args ) // $entry->string;
+ return $self->_translate_tag( $entry->module, $entry->tag, $entry->printable_args ) // $entry->string;
}
|
So far, so good. I wanted to see if there was any improvement in performance but it seems that the time to test a zone has too high of a variance to allow me to arrive at a conclusive result. |
|
However, when I run the unit tests for the test modules (i.e. |
Thanks for the measurements that's really good to know! |
|
Please re-review, the tests are now passing. |
I redid some measurements now that the tests are passing, the gain is only marginal. |
Is this a correct description of this PR? |
mattias-p
left a comment
There was a problem hiding this comment.
Super nice to get rid of the call stack walking! I added comments for a few minor things but all in all I like it a lot.
matsduf
left a comment
There was a problem hiding this comment.
Please provide a better text under "Purpose" so that you easily can see what this PR is about.
I tried to improve it. @mattias-p please can you re-review? |
Is the new presentation of the module and test case names in mostly lower case part of the purpose? Or is that just a side effect? |
It was the main motivation but has become a side effect, I updated the description to mention it in the purpose section. |
v2023.2 release testingTested based on the "How to test" section and woks as expected. |
Purpose
This PR aims to provide an interface to manually set the module and test case name in the Logger.
This is to avoid unnecessary calls to
callersand decouple the module / test case name from the file name / method name.This PR also addresses the letter case of test cases and module to fit the updated specification.
Context
zonemaster/zonemaster#1200
Changes
_emit_logis used instead ofinfo$Zonemaster::Engine::Logger::TEST_CASE_NAMEis used to set the test case nameSyestemandUnspecified).How to test this PR
Run a test using the CLI,
check that