Skip to content
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
22 changes: 22 additions & 0 deletions tests/utils/stl/test/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,24 @@ def pretty(self, config, litParams):
return 'exclude run.pl tags {}'.format(str(self._taglist))


def beNice(prio: str) -> list[ConfigAction]:
"""
Set the process priority to run tests with.
"""
try:
import psutil
priority_map = {
'normal': psutil.NORMAL_PRIORITY_CLASS,
'low': psutil.BELOW_NORMAL_PRIORITY_CLASS,
'idle': psutil.IDLE_PRIORITY_CLASS,
}
psutil.Process().nice(priority_map[prio])
except ImportError:
import sys
print(f'NOTE: Module "psutil" is not installed, so the priority setting "{prio}" has no effect.', file=sys.stderr)
return []


def getDefaultParameters(config, litConfig):
DEFAULT_PARAMETERS = [
Parameter(name='long_tests', choices=[True, False], type=bool, default=True,
Expand All @@ -47,6 +65,10 @@ def getDefaultParameters(config, litConfig):
Parameter(name="notags", type=list, default=[],
help="Comma-separated list of run.pl tags to exclude tests",
actions=lambda tags: [AddRunPLNotags(tags)]),
Parameter(name="priority", choices=["idle", "low", "normal"], default="idle", type=str,
help='Process priority to run tests with: "idle" (the default), "low", or "normal". ' +
'Module "psutil" must be installed for this to have any effect.',
actions=lambda prio: beNice(prio)),
]

return DEFAULT_PARAMETERS