Skip to content

Handle missing attribute for merge/minus operation - #254

Merged
psss merged 1 commit into
mainfrom
merge-fix
Nov 29, 2024
Merged

psss merged 1 commit into
mainfrom
merge-fix

Conversation

@lukaszachy

@lukaszachy lukaszachy commented Sep 3, 2024 •

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor 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

LecrisUT commented Sep 3, 2024

Copy link
Copy Markdown
Member

Can you comment with an example fmf file for this?

@lukaszachy

Copy link
Copy Markdown
Contributor 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..

@lukaszachy

Copy link
Copy Markdown
Contributor 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

psss commented Sep 4, 2024

Copy link
Copy Markdown
Member

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.

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.

@psss psss 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.

Looks good & makes sense. Thanks!

@psss psss added the base label Nov 29, 2024
@psss
psss merged commit 831c2c5 into main Nov 29, 2024
@psss
psss deleted the merge-fix branch November 29, 2024 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants