import errno


def parsettestcases(path):
    """read a .t test file, return a set of test case names

    If path does not exist, return an empty set.
    """
    cases = []
    try:
        with open(path, "rb") as f:
            for l in f:
                if l.startswith(b"#testcases "):
                    cases.append(sorted(l[11:].split()))
    except IOError as ex:
        if ex.errno != errno.ENOENT:
            raise
    return cases