Changeset f85bc15 for src/tests/pybin


Ignore:
Timestamp:
Jul 23, 2018, 4:46:36 PM (7 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, no_list, persistent-indexer, pthread-emulation, qualifiedEnum
Children:
552f5cb
Parents:
46782ab5
Message:

Test now work outside of tree except for io2

Location:
src/tests/pybin
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/tests/pybin/settings.py

    r46782ab5 rf85bc15  
     1from __future__ import print_function
     2
     3import os
    14import sys
     5
     6try :
     7        sys.path.append(os.getcwd())
     8        from config import *
     9
     10        SRCDIR = os.path.abspath(SRCDIR)
     11        BUILDDIR = os.path.abspath(BUILDDIR)
     12except:
     13        print('ERROR: missing config.py, re-run configure script.', file=sys.stderr)
     14        sys.exit(1)
    215
    316class Architecture:
     
    6679        arch       = Architecture(options.arch)
    6780
     81
    6882def updateMakeCmd(force, jobs):
    6983        global make
  • src/tests/pybin/test_run.py

    r46782ab5 rf85bc15  
    3333
    3434        def expect(self):
    35                 return ("%s/.expect/%s%s.txt" % (self.path, self.name, '' if not self.arch else ".%s" % self.arch))
     35                return ("%s.expect/%s%s.txt" % (os.path.join(settings.SRCDIR, self.path), self.name, '' if not self.arch else ".%s" % self.arch))
    3636
    3737        def error_log(self):
    38                 return ("%s/.err/%s.log"    % (self.path, self.name))
     38                return ("%s.err/%s.log"    % (os.path.join(settings.BUILDDIR, self.path), self.name))
    3939
    4040        def output_log(self):
    41                 return ("%s/.out/%s.log"    % (self.path, self.name))
     41                return ("%s.out/%s.log"    % (os.path.join(settings.BUILDDIR, self.path), self.name))
    4242
    4343        def input(self):
    44                 return ("%s/.in/%s.txt"     % (self.path, self.name))
     44                return ("%s.in/%s.txt"     % (os.path.join(settings.SRCDIR, self.path), self.name))
    4545
    4646        def target_output(self):
     
    4949        def target(self):
    5050                return os.path.join(self.path, self.name)
     51
     52        def target_executable(self):
     53                return os.path.join(settings.BUILDDIR, self.path, self.name)
    5154
    5255        @classmethod
  • src/tests/pybin/tools.py

    r46782ab5 rf85bc15  
    99import stat
    1010import sys
     11import fileinput
    1112
    1213from pybin import settings
     
    3334                out, err = proc.communicate()
    3435                return proc.returncode, out
     36
     37def is_ascii(fname):
     38        if not os.path.isfile(fname):
     39                return False
     40
     41        code, out = sh("file %s" % fname, print2stdout = False)
     42        if code != 0:
     43                return False
     44
     45        match = re.search(".*: (.*)", out)
     46
     47        if not match:
     48                return False
     49
     50        return match.group(1) == "ASCII text"
    3551
    3652# Remove 1 or more files silently
     
    105121# helper function to replace patterns in a file
    106122def file_replace(fname, pat, s_after):
    107     # first, see if the pattern is even in the file.
    108     with open(fname) as f:
    109         if not any(re.search(pat, line) for line in f):
    110             return # pattern does not occur in file so we are done.
    111 
    112     # pattern is in the file, so perform replace operation.
    113     with open(fname) as f:
    114         out_fname = fname + ".tmp"
    115         out = open(out_fname, "w")
    116         for line in f:
    117             out.write(re.sub(pat, s_after, line))
    118         out.close()
    119         os.rename(out_fname, fname)
     123        file = fileinput.FileInput(fname, inplace=True, backup='.bak')
     124        for line in file:
     125                print(line.replace(pat, s_after), end='')
     126        file.close()
    120127
    121128# helper function to check if a files contains only a specific string
     
    140147# transform path to canonical form
    141148def canonicalPath(path):
    142         return os.path.join('.', os.path.normpath(path) )
     149        abspath = os.path.abspath(__main__.__file__)
     150        dname = os.path.dirname(abspath)
     151        return os.path.join(dname, os.path.normpath(path) )
    143152
    144153# compare path even if form is different
     
    151160                for name in names:
    152161                        path = os.path.join(dirname, name)
    153 
    154162                        op( path )
    155163
    156164        # Start the walk
    157         os.path.walk('.', step, '')
     165        abspath = os.path.abspath(__main__.__file__)
     166        dname = os.path.dirname(abspath)
     167        os.path.walk(dname, step, '')
    158168
    159169################################################################################
Note: See TracChangeset for help on using the changeset viewer.