testutil/dott: normalize error messages

Summary:
run-tests.py uses common-pattern.py to normalize error messages to things
like `$ENOENT$`. Implement that behavior.

Reviewed By: xavierd

Differential Revision: D16209208

fbshipit-source-id: 3e609cc16442f80b844264f93dce9ea46517458d
This commit is contained in:
Jun Wu 2019-07-17 20:59:57 -07:00 committed by Facebook Github Bot
parent 27908b883c
commit 08c15a105a

View File

@ -157,3 +157,28 @@ _normalizefuncs = []
# Decorator. Add an output normalizing function.
normalizeoutput = _normalizefuncs.append
_errors = {
br"$ENOENT$": (
# strerror()
br"No such file or directory",
# FormatMessage(ERROR_FILE_NOT_FOUND)
br"The system cannot find the file specified",
),
br"$ENOTDIR$": (
# strerror()
br"Not a directory",
# FormatMessage(ERROR_PATH_NOT_FOUND)
br"The system cannot find the path specified",
),
}
@normalizeoutput
def _normalizeerr(out, _errors=_errors):
"""Translate error messages to '$ENOENT$'"""
for name, values in _errors.items():
for value in values:
out = out.replace(value, name)
return out