-
Notifications
You must be signed in to change notification settings - Fork 143
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
Expose "key address" to normalization callbacks #1869
Conversation
bec564b
to
2912b56
Compare
2912b56
to
2b3de71
Compare
Hi @happz, your PR looks good to me. And I also tested your patch by updating
(tmt) huanli@kvm-01-guest01:dev$ git branch
* dev.huanli.1881.20230417
main
normalize-include-key-address
(tmt) huanli@kvm-01-guest01:dev$ git diff
diff --git a/tmt/base.py b/tmt/base.py
index 7347dc4..7f316a3 100644
--- a/tmt/base.py
+++ b/tmt/base.py
@@ -766,7 +766,11 @@ class Test(Core, tmt.export.Exportable['Test']):
# TODO: mandatory schema validation would remove the need for Optional...
# `test` is mandatory, must exist, so how to initialize if it's missing :(
if value is None:
- return ShellScript('')
+ raise tmt.utils.NormalizationError(key_address, value, 'string')
+
+ # Raise an error if value is not a string, e.g. False or True
+ if not isinstance(value, str):
+ raise tmt.utils.NormalizationError(key_address, value, 'string')
return ShellScript(value)
(tmt) huanli@kvm-01-guest01:foo$ pwd
/home/huanli/dev/1001869/foo/tests/foo
(tmt) huanli@kvm-01-guest01:foo$ cat main.fmf
summary: Concise summary describing what the test does
test: false
framework: beakerlib
(tmt) huanli@kvm-01-guest01:foo$ tmt run -avvv provision -h local
/var/tmp/tmt/run-001
Found 1 plan.
/plans
summary: Basic smoke test
discover
how: fmf
order: 50
directory: /home/huanli/dev/1001869/foo
warn: /tests/foo:test - False is not of type 'string'
finish
prune: Prune plan workdir '/var/tmp/tmt/run-001/plans'.
summary: 0 tasks completed
Field "/tests/foo:test" can be string, "bool" found.
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Looks good !!! |
2b3de71
to
46e7b0c
Compare
eecdddc
to
85b182a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just typos found.
e9bfa79
to
9529a77
Compare
Fix for testing-farm:fedora-38-x86_64:internal-plugins in progress |
9529a77
to
55c5982
Compare
ede7100
to
8b0c81c
Compare
8b0c81c
to
9295641
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, ty!
Keys belong to various objects like step phases or fmf ids, and tmt can do better job when reporting unexpected input values. Another step is to expose the location of the key to normalization callbacks and a dedicated exception for reporting the violations in a unified manner. The key address is already used by schema validation when reporting validation errors, and while it's often subpar, it enhances error messages a bit. In the follow-up patches, improving the addresses will happen - for example, sometimes a class name is printed instead of a fmf node name, usually because the node name is not available.
2b951f1
to
75bfbbd
Compare
@@ -522,7 +521,7 @@ class PrepareInstallData(tmt.steps.prepare.PrepareStepData): | |||
) | |||
|
|||
|
|||
@tmt.steps.provides_method('install') | |||
@ tmt.steps.provides_method('install') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this change intentional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, nope, that does not look like an intention. It shouldn't have any effect, but it's not supposed to happen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, we can fix with some other patch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's the fix: #2128
Keys belong to various objects like step phases or fmf ids, and tmt can do a better job when reporting unexpected input values. Another step is to expose the location of the key to normalization callbacks and a dedicated exception for reporting the violations in a unified manner. The key address is already used by schema validation when reporting validation errors, and while it's often subpar, it enhances error messages a bit. In the follow-up patches, improving the addresses will happen - for example, sometimes a class name is printed instead of an fmf node name, usually, because the node name is not available.
Keys belong to various objects like step phases or fmf ids, and tmt can do better job when reporting unexpected input values. Another step is to expose the location of the key to normalization callbacks and a dedicated exception for reporting the violations in a unified manner.
The key address is already used by schema validation when reporting validation errors, and while it's often subpar, it enhances error messages a bit.
In the follow-up patches, improving the addresses will happen - for example, sometimes a class name is printed instead of a fmf node name, usually because the node name is not available.