Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/pybin/tools.py

    r09bbe78 rf866d15  
    8888                raise
    8989
     90def is_empty(fname):
     91        if not os.path.isfile(fname):
     92                return True
     93
     94        if os.stat(fname).st_size == 0:
     95                return True
     96
     97        return False
     98
    9099def is_ascii(fname):
    91100        if settings.dry_run:
    92101                print("is_ascii: %s" % fname)
    93                 return True
     102                return (True, "")
    94103
    95104        if not os.path.isfile(fname):
    96                 return False
    97 
    98         code, out = sh("file %s" % fname, output_file=subprocess.PIPE)
     105                return (False, "No file")
     106
     107        code, out = sh("file", fname, output_file=subprocess.PIPE)
    99108        if code != 0:
    100                 return False
     109                return (False, "'file EXPECT' failed with code {}".format(code))
    101110
    102111        match = re.search(".*: (.*)", out)
    103112
    104113        if not match:
    105                 return False
    106 
    107         return match.group(1).startswith("ASCII text")
     114                return (False, "Unreadable file type: '{}'".format(out))
     115
     116        if "ASCII text" in match.group(1):
     117                return (True, "")
     118
     119        return (False, "File type should be 'ASCII text', was '{}'".format(match.group(1)))
    108120
    109121def is_exe(fname):
Note: See TracChangeset for help on using the changeset viewer.