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

runtest: do not try to load pyyaml when reporting is disabled #477

Merged
merged 1 commit into from
Dec 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 27 additions & 12 deletions scripts/testing/runtest
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,28 @@ import socket
import sys
import termios
import time
import yaml

# --------------------------------------------------------------------
class folded_unicode(str):
pass
try:
import yaml

class literal_unicode(str):
pass
except ModuleNotFoundError:
yaml = None

def folded_unicode_representer(dumper, data):
return dumper.represent_scalar(u'tag:yaml.org,2002:str', data, style='>')
def literal_unicode_representer(dumper, data):
return dumper.represent_scalar(u'tag:yaml.org,2002:str', data, style='|')
else:
class folded_unicode(str):
pass

class literal_unicode(str):
pass

def folded_unicode_representer(dumper, data):
return dumper.represent_scalar(u'tag:yaml.org,2002:str', data, style='>')
def literal_unicode_representer(dumper, data):
return dumper.represent_scalar(u'tag:yaml.org,2002:str', data, style='|')

yaml.add_representer(folded_unicode , folded_unicode_representer)
yaml.add_representer(literal_unicode, literal_unicode_representer)
yaml.add_representer(folded_unicode , folded_unicode_representer)
yaml.add_representer(literal_unicode, literal_unicode_representer)

# --------------------------------------------------------------------
@clib.asynccontextmanager
Expand Down Expand Up @@ -800,7 +806,16 @@ async def _main():
mainconfig.hostname = socket.gethostname()
mainconfig.timestamp = datetime.datetime.utcnow()

options = _options()
options = _options()

if options.report is not None:
if yaml is None:
print(
'reporting needs the yaml Python module',
file = sys.stderr
)
exit(1)

allscripts = Gather.gatherall(options.scenarios, options.targets)

listener = None
Expand Down
Loading