Skip to content

4583 custom suite name - #4661

Merged
pekkaklarck merged 22 commits into
robotframework:masterfrom
otemek:4583_custom_suite_name
Apr 4, 2023
Merged

pekkaklarck merged 22 commits into
robotframework:masterfrom
otemek:4583_custom_suite_name

Conversation

@otemek

@otemek otemek commented Feb 17, 2023

Copy link
Copy Markdown
Contributor

My proposal of implementation for suite names.
Any questions, ideas, or remarks are welcome as it's my first contribution to the RF project.

@pekkaklarck pekkaklarck left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

On a quick look this looks really promising. I need to take a bit closer look at the code changes and added tests later, but I already noticed these things that need to be addressed:

  • The setting name should be just Name, not Suite Name, to be consistent with Documentation and Metadata that are suite specific as well. It won't then be consistent with Suite Setup/Teardown, but they need the Suite prefix to separate them from Test Setup/Teardown.
  • The setting needs to be translateable. This requires adding name_setting = None to the Language base class in the robot.conf.languages module and English translation to the En class. You can add Finnish translation Nimi there as well.
  • This functionality needs to be documented in the User Guide. This can be done separately after merging this PR as well.

@otemek
otemek requested a review from pekkaklarck February 25, 2023 11:37
@otemek

otemek commented Feb 25, 2023

Copy link
Copy Markdown
Contributor Author

Thanks for the help and I hope I understood it correctly because I've left the token name SUITE_NAME and changed only the value for it as there is already a token "NAME" for tokenizing e.g. keyword names (am I right?)

@pekkaklarck

Copy link
Copy Markdown
Member

I mainly meant the name of the setting you use in the data. I noticed you already changed it to Name which is great.

What token name/type to use is a good question. It didn't occur to me there's already NAME token that's apparently used with settings. I'd in general prefer having less token types and would be fine reusing NAME also with suite names, but we already have TESTCASE_NAME and KEYWORD_NAME so probably it's best to add SUITE_NAME as well. The value of the token type shouldn't really matter, but we've in general used values that match the name like

    TESTCASE_NAME = 'TESTCASE NAME'
    KEYWORD_NAME = 'KEYWORD NAME'

so I guess this should be

    SUITE_NAME = 'SUITE NAME'

@pekkaklarck pekkaklarck left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The added tests look pretty comprehensive, but unfortunately they aren't structured correctly. As the atest/README.rst file explains, tests on the atest/robot side should just validate that features used on the atest/testdata side work correctly. Basically all files using the new Name setting should be on the atest/testdata side and on the atest/robot side you'd have tests that validate that the name is set correctly.

There's existing atest/robot/parsing/suite_settings.robot file for testing other suite related settings. It runs atest/testdata/parsing/suite_settings.robot and validates everything works correctly. It currently checks that ${SUITE.name} is set correctly based on the file name, but you could add Name setting to the file and see that the name is set accordingly. A problem with this approach is that it would be good to have an explicit test for getting suite name from a file name as well. In addition to that, it's a good idea to test that Name works also with __init__.robot files and that with directories the name is got from the directory name by default.

An alternative would be having a separate atest/robot/parsing/suite_name.robot file that tests all aforementioned combinations. Also it would need to run some tests suites where Name is used (and not used). Instead of creating new dummy suites, it would probably be better to add Name to few suites under atest/testdata/misc/suites and run it. Also other tests run atest/testdata/misc/suites so you may need to update them after making changes, but that shouldn't be too big a task.

I didn't yet look at the code in detail but on a very quick look it looks really good. I'll review it in more detail once tests have been restructured. If you have any questions about the somewhat complicated test setup or anything else, don't hesitate to ask here or on the #devel channel on our Slack.

@pekkaklarck pekkaklarck left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Code looks good but some things still to be done:

  1. There are now tests only on the atest/testdata side which means they aren't actually run as part of the normal acceptance test run. Separate atest/robot/parsing/suite_names.robot file is needed to run them and to validate that suite names are set correctly. If you need help with this, ping me on Slack or ask help here.
  2. As commented separately, it would be good to test also translation.
  3. The code uses Suite Name in some places and Name in others. Should consistently use Name everywhere.
  4. Documentation in the User Guide is missing. That can be done separately once this PR is otherwise ready.

Comment thread src/robot/conf/languages.py Resolved
Comment thread src/robot/parsing/lexer/settings.py Resolved
Comment thread src/robot/conf/languages.py Resolved
Comment thread src/robot/parsing/model/statements.py Resolved
Comment thread src/robot/parsing/lexer/tokens.py Resolved
Comment thread utest/parsing/test_lexer.py Resolved
@otemek

otemek commented Mar 29, 2023 •

Copy link
Copy Markdown
Contributor Author

I've tried to implement this feature as a Name and the token type Token.SUITE_NAME and used existing suites for testing this feature, it is atest/testdata/misc/suite.
I'm aware that there are a bunch of test cases that require change/modification and they are failing right now because of this feature (btw. adding new test cases would be much easier, instead of fixing dozens of them 😅, but sure - I got the point to not expanding code base so much). But before moving on and fixing them I'd be really glad if that approach/implementation can be verified if it's correct/the way how it should be done so I'll know if I'm on the right track 😄 thanks in advance.

@pekkaklarck pekkaklarck left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Awesome work! I think all my comments were about style. Two other things to do in addition to them:

  1. Add localization test. You could just add e.g. # language: Polish into some of the data files and use use Nazwa there instead of Name. Possibly existing localization tests could also be enhanced, but I can do that separately afterwards as well.
  2. Add documentation to the User Guide. I can take care of this as well.

I hope you can take a look my comments and possibly also the two other points above. If you are busy, I can also merge this PR and make these changes myself.

Comment thread atest/robot/core/filter_by_names.robot Resolved
Comment thread atest/robot/parsing/suite_names.robot Resolved
Comment thread atest/robot/parsing/suite_names.robot Resolved
Comment thread atest/robot/parsing/suite_names.robot Outdated

Multi Root Custom Suite Name
Should Be Equal As Strings ${Suite.suites[3].suites[1].name} SubParentSuite3Name
Should Be Equal As Strings ${Suite.suites[3].suites[1].suites[0].name} Another Custom Sub Suite No newline at end of file

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

  1. What does "Multi Root" mean here?
  2. Add newline at the end of the file.

@otemek otemek Apr 2, 2023 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Changed name from Multi Root to Multi Init to indicate that the suite name is placed under multiple folders with __init__.robot initialization file with setting Name. Can it be like that?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't understand what you mean with "placed under multiple folders". Is the file inside a sub folder that's executed? If yes, then something like Custom child suite name would be better. Anyway, the exact name doesn't matter that much.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

renamed to Custom Child Suite Name

Comment thread src/robot/conf/languages.py Resolved
Comment thread src/robot/parsing/lexer/settings.py Resolved
Comment thread atest/robot/core/filter_by_names.robot Outdated
*** Settings ***
Documentation Tests for --test and --suite options.
Resource atest_resource.robot
Test Tags filter_by_names

@pekkaklarck pekkaklarck Apr 3, 2023 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why wasn't this removed? According to the comment above it should have been removed, but either changes haven't been committed and pushed or there's something else going on. Same situation with various other comments that have marked as resolved.

@pekkaklarck

Copy link
Copy Markdown
Member

I enabled running tests on CI and several tests failed due to changes to suite names under atest/testdata/misc. That's as expected but these tests obviously need to be fixed. Can you @otemek take care of that?

It also seems that although my comments have been marked as resolved, changes aren't seen here. Did you forget to commit and push changes?

Other than the above this PR is ready to be merged. Still need to write documentation, but I already promised to do that earlier.

@otemek

otemek commented Apr 3, 2023

Copy link
Copy Markdown
Contributor Author

Sorry about those delays/code not pushed/lags/etc... but as You probably have noticed - I have quite a big problem with finding some time for me to completely take care of this so I don't know if I'll be able to finish this in a reasonable time. If there is anyone else who can make it quicker then I'm totally fine with passing it to someone else :)
P.S. Sorry for the problems

@pekkaklarck

Copy link
Copy Markdown
Member

No worries! We all have our time pressures and with some new features there's surprisingly lot to do to get everything done. If you don't have time to continue, that's totally fine. We can either continue from here or post-pone this to RF 6.2.

One reason there are so many tests to be fixed is that you added a new test under atest/testdata/misc/suites. That breaks all tests running that directory and checking test counts. I'm not sure is the new test needed in this case, though. I believe it would have been possible to just change suite names which wouldn't have had such a big effect on other tests. Unless that new test is really needed, I'd just remove the whole subsubsuites3.

@pekkaklarck

Copy link
Copy Markdown
Member

I looked at the changes again and this is so close to be ready that I believe we should get this in still in RF 6.1.

As I wrote above, the new test under atest/testdata/misc/suites is the reason why so many existing tests need to be changed. You seem to have already fixed many of them and I now enabled CI again to see are there still failures. If there are, removing the new test may be easier way forward than fixing the remaining failures. Some changes would need to be reverted after removing the test but that is likely a smaller task.

@pekkaklarck

Copy link
Copy Markdown
Member

I try to get those tests fixed and fixes pushed to this same PR!

@pekkaklarck

Copy link
Copy Markdown
Member

I fixed test and pushed changes here. Looking at the history, there are now some commits that are related to recent changes in master, not to actual changes in this PR. I don't know are they due to me pushing these changes without first merging/rebasing locally or were they here already. Well, if tests pass I'll merge this PR and squash all changes. Hopefully that makes the history clean as well.

@pekkaklarck
pekkaklarck force-pushed the 4583_custom_suite_name branch from 20bf6b1 to bd40495 Compare April 4, 2023 12:20
@pekkaklarck

Copy link
Copy Markdown
Member

Rebasing the PR branch locally fixed the history but then needed to force-push changes here. Changes look good and I'll merge this if the CI run succeeds.

@pekkaklarck
pekkaklarck merged commit 609b6cb into robotframework:master Apr 4, 2023
@otemek

otemek commented Apr 5, 2023

Copy link
Copy Markdown
Contributor Author

Thanks for the help and for making it done

@otemek
otemek deleted the 4583_custom_suite_name branch April 5, 2023 07:22
@pekkaklarck

Copy link
Copy Markdown
Member

Thanks for your contribution!

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.

2 participants