-
Notifications
You must be signed in to change notification settings - Fork 117
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
[RFE] provide way to output machine parseable information about tests #2056
Comments
Would $ tmt test export --how yaml | yq -r '.[] | "\(.name) \(.require | join(" "))"'
/tests/provision/virtual/dependencies tmt-provision-virtual beakerlib
/tests/artemis/noop tmt
/tests/clean/chain tmt beakerlib
/tests/clean/guests tmt beakerlib
/tests/clean/runs tmt beakerlib
/tests/core/adjust tmt tmt-provision-container beakerlib
/tests/core/debug tmt beakerlib
/tests/core/docs tmt beakerlib
/tests/core/dry tmt beakerlib
... |
Not sure where your yq command comes from, I haven't found that packaged in Fedora. I don't know tools working with yaml format directly, but it seems I would be able to use |
JSON is not among supported export formats, but it should be trivial to add. Absolutely doable, let´s add it. WRT the plain key=value, could you provide an example, how would it look like? It’s really easy to add new format, adding a well-defined one for tools happier with key=value rather than with YAML shouldn’t be complex. |
I have put quick&dirty attempt to print values in shell-like manner. #!/usr/bin/python3
import sys
import subprocess
"""
Convert tmt tests metadata to shell parseable output.
No proper escaping of strings is done!
"""
def print_keyval(keyname, value):
escaped = value.replace('\'', '\\\'')
print(keyname+'=\''+escaped+'\'')
def print_prop(test, prop, delimiter=' '):
keyname = prop.upper()
if isinstance(test[prop], list):
print_keyval(keyname, delimiter.join(test[prop]))
elif isinstance(test[prop], str):
print_keyval(keyname, test[prop])
else:
print_keyval(keyname, str(test[prop]))
def print_one(test):
for k in test.keys():
print_prop(test, k)
process = subprocess.run(["tmt", "test", "export", "--how", "dict", "."], capture_output=True, check=True)
textdata = process.stdout
#print(textdata, type(textdata))
testdata = eval(textdata, {})
if len(testdata) > 1:
raise("Invalid input data")
print_one(testdata[0]) I can do with it:
Which is kind of what I were looking for. |
Proposed a JSON export in #2058, for a good measure. We already support YAML, there's no technical reason to not support JSON as well. |
I am looking for a way to make
tmt test show .
to print information about test in current directory. I would like to have machine parseable values of selected fields.The most interesting fields for me are
require:
andrecommend:
fields. Unfortunately processing current list of require packages from shell is difficult. Could be added some parameter to output those parameter in machine processable name? For packages list ideal would be just space-separated list of required packages. Without decorations like "and" between packages. Always printed the same way, regardless form used in fmf file.I would like to use that to implement 1minutetip compatibility glue. But haven't found good alternatives.
The text was updated successfully, but these errors were encountered: