Skip to content
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

Handle missing attribute for merge/minus operation #254

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

lukaszachy
Copy link
Collaborator

@lukaszachy lukaszachy commented Sep 3, 2024

Operations ~, -~ and - should do nothing if the key is not present. Otherwise they are difficult to use with shared adjust snippets as keys might not always be present.

@lukaszachy lukaszachy added this to the 1.5 milestone Sep 3, 2024
@lukaszachy
Copy link
Collaborator Author

Added to the milestone as I intend to use this with 'adjust-tests' feature of tmt and it is very easy to hit KeyError when some test doesn't have both require/recommend set...

@LecrisUT
Copy link
Contributor

LecrisUT commented Sep 3, 2024

Can you comment with an example fmf file for this?

@lukaszachy
Copy link
Collaborator Author

For example conflicting mariadb vs mysql server but test can do both... Recommend package can be skipped, but if for some reason you change the order -> failure during prepare.

/1:
  test: echo
  require:
   - mysql
/2:
  test: echo
  recommend:
   - mariadb
   - mysql

So if I was to use this from other plan (and I don't have possiblity to "fix" test metadata (eg. not my repo):

discover:
 how: fmf
 adjust-tests:
 - require-: [mysql]
 - recommend-: [mysql]

And now I can be sure that mysql isn't require by any test..

Operations '~', '-~' and '-' should do nothing if the key is not
present. Otherwise they are difficult to use with shared adjust
snippets as keys might not always be present.
@lukaszachy
Copy link
Collaborator Author

@happz has good points that this might hide typo in the key names, making it harder to spot (e.g. why there still is 'foo' in require why I clearly have 'requre-:[foo]' in data...)

@psss
Copy link
Collaborator

psss commented Sep 4, 2024

So, a bit cleaner (perhaps) approach discussed on the chat would be to use require: [] at the top of the test repository to make sure that the key is always defined. But as @lukaszachy mentioned above, there might be a scenario when user does not have write access to the test repository. And for that use case the unconditional removal could be really useful.

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.

3 participants