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

    w = Workspace(uid='vcsjob-execute-t3')

    # create the jobs tree
    def make_vcsjob_tree():
        path = w.make_tempdir()
        f = open(os.path.join(path, '.vcsjob'), 'w')
        # broken JSON file:
        f.write('{ "executables": [ { "path": "printenv.sh"')
        f.close()
        f = open(os.path.join(path, 'printenv.sh'), 'w')
        f.write('#! /bin/bash\nprintenv\n')
        f.close()
        os.chmod(os.path.join(path, 'printenv.sh'), 0755)
        return path

    jobs = make_vcsjob_tree()

    exc = None
    try:
        vcsjob.list_jobs(jobs_dir=jobs)
    except Exception, e:
        exc = e
Пример #2
0
def t1():
    pretty = '%s t1' % __file__
    print(pretty)

    exc = None
    try:
        vcsjob.list_jobs(None, None)
    except Exception, e:
        exc = e
Пример #3
0
def t7():
    pretty = '%s t7' % __file__
    print(pretty)

    def make_vcsjob_tree(workspace):
        path = workspace.make_tempdir()
        f = open(os.path.join(path, '.vcsjob'), 'w')
        f.write('{ "executables": [ { "path": "job.sh", "tags":["THIS"] } ] }')
        f.close()
        f = open(os.path.join(path, 'job.sh'), 'w')
        f.write('#! /bin/bash\nprintenv\n')
        f.close()
        os.chmod(os.path.join(path, 'job.sh'), 0755)
        return path

    w = Workspace(uid='vcsjob-execute-t7')
    jobs = make_vcsjob_tree(w)
    result = vcsjob.list_jobs(jobs_dir=jobs, job_tags=['THAT'])

    if result != []:
        print(
            'FAIL %s: vcsjob.list_jobs() returned a nonempty list even though '
            'there were no jobs to list' % pretty)
        return

    w.delete()
Пример #4
0
def t2():
    pretty = '%s t2' % __file__
    print(pretty)

    try:
        result = vcsjob.list_jobs(jobs_dir='does_not_exist', job_tags=None)
        print('FAIL %s: vcsjob.list_jobs() with jobs_dir that points to a '
              'nonexistent directory should raise exception' % pretty)
    except Exception, e:
        if 'not a jobs directory: does_not_exist' != str(e):
            print('FAIL %s: wrong exception message: %s' % (pretty, str(e)))
Пример #5
0
    def verify_ret(pretty, path, exp_count, tags):
        try:
            result = vcsjob.list_jobs(path, tags)
            if len(result) != exp_count:

                print(
                    'FAIL %s: unexpected number of jobs returned: %d, expected'
                    ' : %d' % (pretty, len(result), exp_count))
                return
        except Exception, e:
            print('FAIL %s: got exception: %s' % (pretty, str(e)))
            return
Пример #6
0
def t5():
    pretty = '%s t5' % __file__
    print(pretty)

    w = Workspace(uid='vcsjob-execute-t5')

    # create the jobs tree
    def make_vcsjob_tree():
        path = w.make_tempdir()
        f = open(os.path.join(path, '.vcsjob'), 'w')
        f.write('{ "executables": [ { "path": "no_such_file" } ] }')
        f.close()
        return path

    jobs = make_vcsjob_tree()

    exc = None
    try:
        vcsjob.list_jobs(jobs_dir=jobs)
    except Exception, e:
        exc = e
Пример #7
0
def t4():
    pretty = '%s t4' % __file__
    print(pretty)

    w = Workspace(uid='vcsjob-execute-t4')

    # create the jobs tree
    def make_vcsjob_tree():
        path = w.make_tempdir()
        f = open(os.path.join(path, '.vcsjob'), 'w')
        # no "path" attr:
        f.write('{ "executables": [ { "PATH": "printenv.sh" } ] }')
        f.close()
        return path

    jobs = make_vcsjob_tree()

    exc = None
    try:
        result = vcsjob.list_jobs(jobs_dir=jobs)
    except Exception, e:
        exc = e