Exemplo n.º 1
0
def main():
    args = args_parser().parse_args()
    print("Creating temporary test installation in", repr(config.pseudo_install_dir), "to make files available to Jenkins.")
    install_script = jp(here, 'tmp_install.sh')
    rc = subprocess.call([install_script])
    if rc:
        print("Failed test installation to. Install script is:", repr(install_script), file=sys.stderr)
        print("Warning: Some tests will fail!", file=sys.stderr)

    print("\nRunning tests")
    try:
        if False or args.pytest_args or args.files:
            extra_args = args.pytest_args.split(' ') + args.files if args.pytest_args else args.files
            subprocess.check_call(['py.test', '--capture=sys', '--instafail'] + extra_args)
            test_cfg.unmock()
            sys.exit(subprocess.call(['py.test', '--capture=sys', '--instafail'] + extra_args))

        run_tests(False, here + '/.coverage_mocked_rc')
        validate_all_demos()

        test_cfg.unmock()
        parallel = test_cfg.skip_job_load() | test_cfg.skip_job_delete()
        if test_cfg.use_jenkinsapi():
            print("Using jenkinsapi_wrapper")
            run_tests(parallel, here + '/.coverage_jenkinsapi_rc')
        else:
            print("Using specialized_api")
            run_tests(parallel, here + '/.coverage_real_rc')
        validate_all_demos(execute_script=True)

        print("\nTesting setup.py")
        user = getpass.getuser()
        install_prefix = '/tmp/' + user
        tmp_packages_dir = install_prefix + '/lib/python2.7/site-packages'
        os.environ['PYTHONPATH'] = tmp_packages_dir
        if os.path.exists(tmp_packages_dir):
            shutil.rmtree(tmp_packages_dir)
        os.makedirs(tmp_packages_dir)
        subprocess.check_call([sys.executable, jp(here, '../setup.py'), 'install', '--prefix', install_prefix])
        shutil.rmtree(jp(here, '../build'))
    except Exception as ex:
        print('*** ERROR: There were errors! Check output! ***', repr(ex), file=sys.stderr)
        raise

    sys.exit(rc)
Exemplo n.º 2
0
from __future__ import print_function

import os, sys, re
from os.path import join as jp
from peak.util.proxies import ObjectWrapper

here = os.path.abspath(os.path.dirname(__file__))
sys.path.extend([jp(here, '../../..'), jp(here, '../../demo')])

from jenkinsflow.jobload import update_job_from_template
from jenkinsflow.mocked import HyperSpeed

import demo_security as security

from jenkinsflow.test import cfg as test_cfg
if test_cfg.use_jenkinsapi():
    from jenkinsflow import jenkinsapi_wrapper as jenkins
else:
    from jenkinsflow import specialized_api as jenkins
from jenkinsflow.api_base import UnknownJobException, ApiJobMixin, ApiBuildMixin

from jenkinsflow.unbuffered import UnBuffered
sys.stdout = UnBuffered(sys.stdout)

from .base_test_api import TestJob, TestBuild, TestJenkins
from .config import test_tmp_dir, pseudo_install_dir

_file_name_subst = re.compile(r'(_jobs|_test)?\.py')
hyperspeed = HyperSpeed()