tests/readlink.py
author Gregory Szorc <gregory.szorc@gmail.com>
Wed, 31 Jan 2018 11:04:16 -0800
changeset 35893 2f7ab4fb7711
parent 29485 6a98f9408a50
child 45849 c102b704edb5
permissions -rwxr-xr-x
tests: allow [Errno] in output I'm not sure why, but my system is printing "[Errno -5]" before the "No address associated with hostname" message. I suspect a modern version of Python improved errno tracking or something. Add an "[Errno ...]" pattern as optional output to make the test pass. Differential Revision: https://phab.mercurial-scm.org/D1958

#!/usr/bin/env python

from __future__ import absolute_import, print_function

import errno
import os
import sys

for f in sys.argv[1:]:
    try:
        print(f, '->', os.readlink(f))
    except OSError as err:
        if err.errno != errno.EINVAL:
            raise
        print(f, '->', f, 'not a symlink')

sys.exit(0)