Пример #1
0
def t1(w):
    pretty = '%s t1' % __file__
    print(pretty)

    root = find_vcsjob_dir(__file__)
    job  = os.path.join('jobs', 'demo_job.py')
    log  = os.path.join(w.path, 'log.txt')

    try:
        vcsjob.execute_single(root, job, [], log)
    except Exception, e:
        print('FAIL %s: could not log to file: %s' % (pretty, e))
        return False
Пример #2
0
 def verify_ret(path, job, ret):
     backup = None
     try:
         (strio, backup) = redirect()
         result = vcsjob.execute_single(path, job)
         undirect(backup)
         if result != ret:
             print('FAIL: file %s returned: %d, expected : %d' %
                   (job, result, ret))
             return
     except Exception, e:
         undirect(backup)
         print('FAIL %s: got exception: %s' % (pretty, str(e)))
         return
Пример #3
0
def t15():
    pretty = '%s t15' % __file__
    print(pretty)

    w = Workspace(uid='vcsjob-execute-t15')
    path = make_vcsjob_tree(w)
    backup = None
    try:
        (strio, backup) = redirect()
        result = vcsjob.execute_single(path,
                                       exec_target=None,
                                       env_vars=['HOME'])
        undirect(backup)
        print('FAIL %s: exec_target=None should generate exception' % (pretty))
    except Exception, e:
        undirect(backup)
        if 'execution target: None' != str(e):
            print('FAIL %s: wrong error message:\n%s' % (pretty, str(e)))
            return
Пример #4
0
def t9(w):
    pretty = '%s t9' % __file__
    print(pretty)

    root = find_vcsjob_dir(__file__)
    job  = os.path.join('jobs', 'demo_logging.py')
    path = w.make_tempfile()

    os.environ['PYTHONPATH'] = sys.path[0] # makes the UNIT scope work
    status = vcsjob.execute_single(root, job, ['PYTHONPATH'], path)

    if status != 1:
        print('FAIL %s: VCSJOB_LOG_PATH was None' % pretty)
        return False

    with open(path) as f:
        log = f.read().splitlines()
        if log[1] != path:
            print('FAIL %s: wrong path logged: %s' % (pretty, log))
            return False

    return True
Пример #5
0
def t8(w):
    pretty = '%s t8' % __file__
    print(pretty)

    root = find_vcsjob_dir(__file__)
    job  = os.path.join('jobs', 'demo_logging.py')

    strio, backup = redirect()
    os.environ['PYTHONPATH'] = sys.path[0] # makes the UNIT scope work
    status = vcsjob.execute_single(root, job, ['PYTHONPATH'], None)
    undirect(backup)

    if status != 0:
        print('FAIL %s: VCSJOB_LOG_PATH was not None' % pretty)
        return False

    log = strio.getvalue().splitlines()
    if len(log) != 1:
        print('FAIL %s: a log path was logged: %s' % (pretty, log))
        return False

    return True