Review main Merged

74750[TASK] Add tests for log `#[Channel(...)]` attribute

crell CR +2 V +2 Normal +221 −1 updated 07/26/22, 21:05

Commit message

v11 introduced support for using a Channel attribute to define
what log channel should be injected into a class, either via
the constructor or the LoggingAwareInterface. However, the
initial patch lacked any tests.

This patch adds basic tests to verify that the attribute works,
and indirectly document it.

Review

  • Code review CR +2 Done
    • Stefan Bürk +2
    • Christian Kuhn +1
  • Verified V +2 Done
    • Stefan Bürk +2
    • Christian Kuhn +1
    • core-ci +1 CI

Issues 3

Files 7

Review log 3852

Show 1927 earlier messages
  1. crell uploaded patch set 1 05/26/22, 20:56

  2. core-ci voted on patch set 1 V -1 05/26/22, 21:04 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/27482

  3. Simon Schaufelberger commented on patch set 1 05/26/22, 21:51

    > It should be safe to backport to v11 as well. this should not be part of the commit message imho.
  4. Simon Schaufelberger commented on patch set 1 05/26/22, 21:56

    LoggerAwareChannelTest.php:54

    this should be covered by the phpstorm meta file, or? In that case, it can be dropped.
  5. Simon Schaufelberger commented on patch set 1 V -1 CR -1 05/26/22, 21:58

    open CGL issues exist.
  6. crell commented on patch set 1 05/27/22, 14:18

    LoggerAwareChannelTest.php:54 Reply

    Done
  7. crell uploaded patch set 2 05/27/22, 14:26

  8. core-ci voted on patch set 2 V +1 05/27/22, 14:34 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/27495

  9. Simon Schaufelberger voted on patch set 2 CR +1 05/27/22, 15:38

  10. Oliver Klee voted on patch set 2 V +1 06/03/22, 15:41

  11. Stefan Bürk commented on patch set 2 CR -1 06/03/22, 16:57

    ConstructorAttributeChannelTester.php:4

    Header comment missing.

    ConstructorAttributeChannelTester.php:14

    Mh. Want start here a little discussion how to handle "attributes" on method argument layer ... Personally I would suggest, if we are starting with this kind of syntax, to use this with line breaking the arguments and having the attributes above the argument: ``` public function __constructr( #[Channel('beep') LoggerInterface $logger ) { } ``` Maybe there has been discussions about it, and I missed some documentations about it. What are other feelings and opinions about this ? Beside this .. can this be used with "CCP" ? (Not to change this now, just as a general question). Makes the backport easier as no property has bee added than etc.

    LoggerAwareClassAttributeChannelTester.php:4

    Header comment missing.

    Services.yaml:5

    Public as default feels kind of wrong, even for a "test extension". At least, it's not the TYPO3 way. Maybe raw symfony has public true as default.

    DummyWriter.php:4

    Header comment missing.

    DummyWriter.php:5

    Test/Dummy classes should be under a "Fixture/xxx" folder. This has some seperations between core, test and fixture classes. Is done already on other places too. So please move the file correspondingly and adjust the namespace afterwards.

    LoggerAwareChannelTest.php:4

    Header comment missing.

    LoggerAwareChannelTest.php:51

    superflous empty line

    LoggerAwareChannelTest.php:66

    superflous empty line
  12. crell commented on patch set 2 06/03/22, 17:33

    ConstructorAttributeChannelTester.php:4 Reply

    Done

    ConstructorAttributeChannelTester.php:14 Reply

    I'm not aware of any convention on this point yet. I suspect FIG will develop one within the next few months, probably. (I'm on the new working group for evolving coding standards. It hasn't come up yet, but it very likely will soon.) Whatever they come up with is what we should probably follow. My personal take at the moment is that adding an attribute should not, in itself, force going to a new line, but if it adds enough to the line length that it makes sense to break out to separate lines then it should go above the parameter, as in Stefan's sample. Attributes are totally CPP compatible, in which case they end up applying to both the parameter and the property, as appropriate. I didn't use CPP in this case to make it backportable, although... that doesn't much matter as the behavior here is only relevant in PHP 8 anyway, so the test should be marked as such. So it probably can be CPPified safely, whether the attribute is inlined or not.

    LoggerAwareClassAttributeChannelTester.php:4 Reply

    Done

    Services.yaml:5 Reply

    It's necessary since the test classes are requested through DI in the test. The alternative is to not auto-scan the directory but manually add both classes with a public flag, but... that just seems like extra typing to end up in exactly the same place. Can the public flag be put on the second YAML block below, with the `resource` entry? I don't know that is an improvement, though.

    DummyWriter.php:4 Reply

    Done

    DummyWriter.php:5 Reply

    Done

    LoggerAwareChannelTest.php:4 Reply

    Done

    LoggerAwareChannelTest.php:51 Reply

    Done

    LoggerAwareChannelTest.php:66 Reply

    Done
  13. crell uploaded patch set 3 06/03/22, 17:41

  14. core-ci voted on patch set 3 V +1 06/03/22, 17:48 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/27691

  15. Oliver Klee voted on patch set 3 V +1 06/03/22, 21:57

  16. Simon Schaufelberger wrote 06/04/22, 00:25

    Removed reviewer Simon Schaufelberger.
  17. crell uploaded patch set 4 06/07/22, 21:13

  18. Oliver Klee wrote 06/07/22, 21:18

    Removed reviewer Oliver Klee.
  19. core-ci voted on patch set 4 V -1 06/07/22, 21:21 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/27781

  20. core-ci commented on patch set 4 06/07/22, 22:18 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/27781

  21. core-ci voted on patch set 4 V +1 06/07/22, 22:49 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/27781

  22. crell commented on patch set 4 06/07/22, 23:25

    ConstructorAttributeChannelTester.php:14 Reply

    Done

    Services.yaml:5 Reply

    Done
  23. Stefan Bürk rebased onto patch set 5 07/13/22, 15:00

  24. core-ci voted on patch set 5 V +1 07/13/22, 15:07 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/29072

  25. Stefan Bürk commented on patch set 5 CR -1 07/13/22, 15:13

    There are more - will push later on it. Please see commit message comment.
    Please add the forge issue number of the initial patch (or eventually follow up patches) as "Related:" to the commit message betwen "Resolves" and "Releases". Also add them in forge as related issues to #97695.
  26. crell updated the commit message in patch set 6 07/13/22, 16:40

  27. core-ci voted on patch set 6 V +1 07/13/22, 16:48 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/29076

  1. Stefan Bürk uploaded patch set 7 07/14/22, 23:55

  2. Stefan Bürk commented on patch set 7 07/14/22, 23:59

    Reply

    Done
  3. core-ci voted on patch set 7 V -1 07/15/22, 00:03 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/29176

  4. Stefan Bürk uploaded patch set 8 07/15/22, 00:05

  5. core-ci voted on patch set 8 V +1 07/15/22, 00:12 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/29177

  6. Stefan Bürk updated the commit message in patch set 9 07/15/22, 00:15

  7. Stefan Bürk commented on patch set 9 V +1 CR +1 07/15/22, 00:16

    Reply

    Done
  8. core-ci voted on patch set 9 V +1 07/15/22, 00:22 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/29178

  9. Benni Mack commented on patch set 9 CR -1 07/15/22, 09:06

    composer.json:292

    the test_logger extension needs a composer.json (and this line needs to be removed). This way, autoloader is working and we do not have to touch composer.json (same as with other fixture extensions)
  10. Stefan Bürk commented on patch set 9 07/15/22, 09:33

    composer.json:292 Reply

    Yes and no. And it's not only about autoloading in the test. Ack - test fixture extension should get a dedicated composer.json (as it is planned that extension must have one regardless if composer or legacy install etc). However, there are more plans behind only "autoloading". If this entry is omited in the root composer.json, PHPStorm will say that the namespace is not PSR-4 compatible (if classmap definitions are removed) - and tests are crashing. There are multiple steps planned, just wanted provide the new extension in the minimun current working state which is needed. I will add the composer.json, but we need to have the PSR-4 definition in root composer.json for now. Additionally, a prepared PSR-4 namespace integration test would consider sys-ext composer.json for code files, and root composer.json autoload-dev->psr-4 to validate namespaces in ci. Maybe this can be extended to pre-scan for "all composer.json's" recursivly and build this info up before-hand. Will stop for now, but there were more points on this. As for now, composer.json are not "enforced" needed as tests are running in "legacy mode" (which may change some time in the future if TF can cope with that). Additionally, we not really finished to discuss how we want the composer.json streamlined for the test fixture extension - and as this has to be done for all, I left it out. I can add a first composer.json, but want to keep the PSR-4 definition in the root composer.json for now. Would it be fine for you to delay the fixture extension composer.json to the patch which introduces this for all test fixture extensions (along with streamlining the namespaces and places where they are placed and so on) ?
  11. crell commented on patch set 9 07/21/22, 20:09

    composer.json:292 Reply

    I'm lost then. Are there still pending tasks on this issue? If not, which issue is blocking? (I have no strong feelings about test extension organization.)
  12. Stefan Bürk commented on patch set 9 07/21/22, 20:12

    composer.json:292 Reply

    Talked with Benni. We will add the composer.json at a later point. Resolving this now. I think Benni will remove the -1 after a revisit and if nothing else speaks for him for the -1.
  13. Stefan Bürk commented on patch set 9 07/21/22, 20:12

    composer.json:292 Reply

    Done
  14. Benni Mack voted on patch set 9 CR 0 07/22/22, 06:44

  15. Stefan Bürk rebased onto patch set 10 07/24/22, 16:17

  16. Stefan Bürk voted on patch set 10 V +1 CR +1 07/24/22, 19:06

  17. core-ci voted on patch set 10 V -1 07/24/22, 19:21 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/29475

  18. crell rebased onto patch set 11 07/25/22, 17:22

  19. core-ci voted on patch set 11 V +1 07/25/22, 17:30 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/29506

  20. Stefan Bürk voted on patch set 11 V +1 CR +1 07/25/22, 17:46

  21. Stefan Bürk uploaded patch set 12 07/26/22, 20:52

  22. core-ci voted on patch set 12 V +1 07/26/22, 21:00 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/29587

  23. Christian Kuhn voted on patch set 12 V +1 CR +1 07/26/22, 21:05

  24. Stefan Bürk voted on patch set 12 V +2 CR +2 07/26/22, 21:05

  25. Stefan Bürk merged patch set 13 07/26/22, 21:05