Пример #1
0
def main(options=None):
    options = options or configure()
    validate()

    if not options.output:
        options.output = sys.stdout

    try:
        fetcher = fetchers.get_fetcher(options.testdir)
        tmpdir = tempfile.mkdtemp(prefix='bundletester-')
        atexit.register(shutil.rmtree, tmpdir)
        options.fetcher = fetcher
        options.testdir = fetcher.fetch(tmpdir)
    except fetchers.FetchError as e:
        sys.stderr.write("{}\n".format(e))
        return get_return_data(1, None)

    suite = spec.SuiteFactory(options, options.testdir)

    if not suite:
        sys.stderr.write("No Tests Found\n")
        return get_return_data(3, None)

    report = reporter.get_reporter(options.reporter, options.output, options)
    report.set_suite(suite)
    run = runner.Runner(suite, options)
    report.header()
    if len(suite):
        with utils.juju_env(options.environment):
            [report.emit(result) for result in run()]
    report.summary()
    return_code = report.exit()
    status = get_return_data(return_code, suite)
    return status
Пример #2
0
def main():
    options = configure()
    validate()

    if not options.output:
        options.output = sys.stdout

    try:
        fetcher = fetchers.get_fetcher(options.testdir)
        options.fetcher = fetcher
        options.testdir = fetcher.fetch(
            tempfile.mkdtemp(prefix='bundletester-'))
    except fetchers.FetchError as e:
        sys.stderr.write("{}\n".format(e))
        sys.exit(1)

    suite = spec.SuiteFactory(options, options.testdir)

    if not suite:
        sys.stderr.write("No Tests Found\n")
        sys.exit(3)

    report = reporter.get_reporter(options.reporter, options.output, options)
    report.set_suite(suite)
    run = runner.Runner(suite, options)
    report.header()
    if len(suite):
        with utils.juju_env(options.environment):
            [report.emit(result) for result in run()]
    report.summary()
    report.exit()
Пример #3
0
    def test_run_suite(self):
        logging.basicConfig(level=logging.CRITICAL)
        parser = config.Parser()
        parser.bootstrap = False
        options = O()
        options.dryrun = True
        options.environment = 'local'
        options.failfast = True
        options.tests_yaml=None
        model = models.TestDir({'name': 'testdir',
                                'directory': TEST_FILES,
                                'testdir': TEST_FILES})

        suite = spec.Suite(model, options=options)
        suite.spec(locate('test02'))
        self.assertEqual(suite[0].name, 'test02')
        run = runner.Runner(suite, options)

        results = list(run())
        self.assertEqual(len(results), 1)
        self.assertEqual(results[0]['returncode'], 0)