Ignore:
Timestamp:
Dec 4, 2017, 6:01:29 PM (4 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, resolv-new, with_gc
Children:
209383b
Parents:
0ad0c55
Message:

Major test cleanup by modularizing further into pybin

File:
1 edited

Legend:

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

    r0ad0c55 rbacc36c  
    33from pybin.tools import *
    44
     5import pybin.settings
    56
    67# Test class that defines what a test is
     
    1415                return "{:25s} ({:5s} {:s})".format( self.name, self.arch if self.arch else "Any", self.target() )
    1516
    16         def prepare(self, dry_run):
    17                 sh("mkdir -p %s" % os.path.join(self.path, '.err'), dry_run)
    18                 sh("mkdir -p %s" % os.path.join(self.path, '.out'), dry_run)
    19                 sh("mkdir -p %s" % os.path.join(self.path, '.in' ), dry_run)
     17        def prepare(self):
     18                sh("mkdir -p %s" % os.path.join(self.path, '.err'))
     19                sh("mkdir -p %s" % os.path.join(self.path, '.out'))
     20                sh("mkdir -p %s" % os.path.join(self.path, '.in' ))
    2021
    21         def expect_file(self):
     22        def expect(self):
    2223                return ("%s/.expect/%s.txt" % (self.path, self.name))
    2324
    24         def error_file(self):
     25        def error_log(self):
    2526                return ("%s/.err/%s.log"    % (self.path, self.name))
    2627
    27         def output_file(self):
     28        def output_log(self):
    2829                return ("%s/.out/%s.log"    % (self.path, self.name))
    2930
    30         def input_file(self):
     31        def input(self):
    3132                return ("%s/.in/%s.txt"     % (self.path, self.name))
     33
     34        def target_output(self):
     35                return self.output_log() if not settings.generating else self.expect()
    3236
    3337        def target(self):
    3438                return os.path.join(self.path, self.name)
     39
     40        @classmethod
     41        def valid_name(cls, name):
     42                return not name.endswith( ('.c', '.cc', '.cpp', '.cfa') )
     43
     44        @classmethod
     45        def from_target(cls, target):
     46                test = Test()
     47                test.name = os.path.basename(target)
     48                test.path = os.path.dirname (target)
     49                test.arch = settings.arch.toString() if settings.arch.cross_compile else ''
     50                return test
     51
     52
     53class TestResult:
     54        SUCCESS = 0
     55        FAILURE = 1
     56        TIMEOUT = 124
     57
     58        @classmethod
     59        def toString( cls, retcode ):
     60                if settings.generating :
     61                        if   retcode == TestResult.SUCCESS:     return "Done"
     62                        elif retcode == TestResult.TIMEOUT:     return "TIMEOUT"
     63                        else :                                          return "ERROR code %d" % retcode
     64                else :
     65                        if   retcode == TestResult.SUCCESS:     return "PASSED"
     66                        elif retcode == TestResult.TIMEOUT:     return "TIMEOUT"
     67                        else :                                          return "FAILED with code %d" % retcode
Note: See TracChangeset for help on using the changeset viewer.