Пример #1
0
def main():
    cmd_opts, args = command.get_opts_run()
    out = sys.stdout
    cleaner = command.Cleaner(out)

    if cmd_opts.xserver_headless:
        from sst.xvfbdisplay import Xvfb
        out.write('starting virtual display...')
        display = Xvfb(width=1024, height=768)
        display.start()
        cleaner.add('stopping virtual display...\n', display.stop)

    with cleaner:
        results_directory = os.path.abspath('results')
        command.reset_directory(results_directory)
        factory = browsers.browser_factories.get(cmd_opts.browser_type)
        failures = runtests.runtests(
            args,
            results_directory,
            out,
            test_dir=cmd_opts.dir_name,
            collect_only=cmd_opts.collect_only,
            report_format=cmd_opts.report_format,
            browser_factory=factory(),
            shared_directory=cmd_opts.shared_directory,
            screenshots_on=cmd_opts.screenshots_on,
            concurrency_num=cmd_opts.concurrency,
            failfast=cmd_opts.failfast,
            debug=cmd_opts.debug,
            extended=cmd_opts.extended_tracebacks,
            excludes=cmd_opts.excludes)

    return failures
Пример #2
0
def main():
    cmd_opts, args = command.get_opts_run()
    out = sys.stdout
    cleaner = command.Cleaner(out)

    if cmd_opts.xserver_headless:
        from sst.xvfbdisplay import Xvfb
        out.write('starting virtual display...')
        display = Xvfb(width=1024, height=768)
        display.start()
        cleaner.add('stopping virtual display...\n', display.stop)

    with cleaner:
        results_directory = os.path.abspath('results')
        command.reset_directory(results_directory,
                                cmd_opts.skip_clean_results)
        factory = browsers.browser_factories.get(cmd_opts.browser_type)
        failures = runtests.runtests(
            args, results_directory, out,
            test_dir=cmd_opts.dir_name,
            collect_only=cmd_opts.collect_only,
            report_format=cmd_opts.report_format,
            browser_factory=factory(),
            shared_directory=cmd_opts.shared_directory,
            screenshots_on=cmd_opts.screenshots_on,
            concurrency_num=cmd_opts.concurrency,
            failfast=cmd_opts.failfast,
            debug=cmd_opts.debug,
            extended=cmd_opts.extended_tracebacks,
            excludes=cmd_opts.excludes,
            xml_results_filename=cmd_opts.xml_results_filename
        )

    return failures
Пример #3
0
def main():
    cmd_opts, args = command.get_opts_run()
    out = sys.stdout
    cleaner = command.Cleaner(out)

    run_django(sst.DEVSERVER_PORT)
    cleaner.add('killing django...\n', kill_django, sst.DEVSERVER_PORT)

    if cmd_opts.xserver_headless:
        from sst.xvfbdisplay import Xvfb
        out.write('starting virtual display...\n')
        display = Xvfb(width=1024, height=768)
        display.start()
        cleaner.add('stopping virtual display...\n', display.stop)

    with cleaner:
        results_directory = os.path.abspath('results')
        command.reset_directory(results_directory)
        os.chdir(os.path.dirname(package_dir))
        test_dir = os.path.join(
            '.',
            'sst',
        )
        shared_directory = os.path.join('.', 'sst', 'selftests', 'shared')
        factory = browsers.browser_factories.get(cmd_opts.browser_type)
        failures = runtests.runtests(args,
                                     results_directory,
                                     out,
                                     test_dir=test_dir,
                                     collect_only=cmd_opts.collect_only,
                                     report_format=cmd_opts.report_format,
                                     browser_factory=factory(),
                                     shared_directory=shared_directory,
                                     screenshots_on=cmd_opts.screenshots_on,
                                     concurrency_num=cmd_opts.concurrency,
                                     failfast=cmd_opts.failfast,
                                     debug=cmd_opts.debug,
                                     extended=cmd_opts.extended_tracebacks,
                                     excludes=cmd_opts.excludes)

    return failures
Пример #4
0
def main():
    cmd_opts, args = command.get_opts_run()
    out = sys.stdout
    cleaner = command.Cleaner(out)

    run_django(sst.DEVSERVER_PORT)
    cleaner.add('killing django...\n', kill_django, sst.DEVSERVER_PORT)

    if cmd_opts.xserver_headless:
        from sst.xvfbdisplay import Xvfb
        out.write('starting virtual display...\n')
        display = Xvfb(width=1024, height=768)
        display.start()
        cleaner.add('stopping virtual display...\n', display.stop)

    with cleaner:
        results_directory = os.path.abspath('results')
        command.reset_directory(results_directory)
        os.chdir(os.path.dirname(package_dir))
        test_dir = os.path.join('.', 'sst',)
        shared_directory = os.path.join('.', 'sst', 'selftests', 'shared')
        factory = browsers.browser_factories.get(cmd_opts.browser_type)
        failures = runtests.runtests(
            args, results_directory, out,
            test_dir=test_dir,
            collect_only=cmd_opts.collect_only,
            report_format=cmd_opts.report_format,
            browser_factory=factory(),
            shared_directory=shared_directory,
            screenshots_on=cmd_opts.screenshots_on,
            concurrency_num=cmd_opts.concurrency,
            failfast=cmd_opts.failfast,
            debug=cmd_opts.debug,
            extended=cmd_opts.extended_tracebacks,
            excludes=cmd_opts.excludes
        )

    return failures
Пример #5
0
def main():
    cmd_opts, args = get_opts_run()

    print '--------------------------------------------------------------'
    print 'starting SST...'

    cleanups = []

    if cmd_opts.browsermob and cmd_opts.run_tests:
        print 'Warning: can not record local traffic from django testproject'

    if cmd_opts.browsermob:
        browsermob_process = run_browsermob_server(cmd_opts.browsermob)

        def browsermob_cleanup():
            browsermob_process.kill()
            browsermob_process.wait()

        cleanups.append(('\nkilling browsermob proxy...', browsermob_cleanup))

    if cmd_opts.run_tests:
        cmd_opts.dir_name = 'selftests'
        run_django()
        cleanups.append(('\nkilling django...', kill_django))

    if cmd_opts.xserver_headless:
        from sst.xvfbdisplay import Xvfb
        print '\nstarting virtual display...'
        display = Xvfb(width=1024, height=768)
        display.start()
        cleanups.append(('\nstopping virtual display...', display.stop))

    if not cmd_opts.quiet:
        print ''
        print '  date time: %s' \
            % datetime.datetime.now().strftime("%Y-%m-%d %H:%M")
        print '  test directory: %r' % cmd_opts.dir_name
        print '  report format: %r' % cmd_opts.report_format
        print '  browser type: %r' % cmd_opts.browser_type
        print '  javascript disabled: %r' % cmd_opts.javascript_disabled
        print '  browswermob proxy launcher: %r' % cmd_opts.browsermob
        print '  shared directory: %r' % cmd_opts.shared_modules
        print '  screenshots on error: %r' % cmd_opts.screenshots_on
        print '  failfast: %r' % cmd_opts.failfast
        print '  debug: %r' % cmd_opts.debug
        print '  headless xserver: %r' % cmd_opts.xserver_headless
        print '  custom options: %r' % cmd_opts.custom
        print ''

    try:
        clear_old_results()
        runtests.runtests(
            args,
            test_dir=cmd_opts.dir_name,
            collect_only=cmd_opts.collect_only,
            report_format=cmd_opts.report_format,
            browser_type=cmd_opts.browser_type,
            javascript_disabled=cmd_opts.javascript_disabled,
            browsermob_enabled=bool(cmd_opts.browsermob),
            shared_directory=cmd_opts.shared_modules,
            screenshots_on=cmd_opts.screenshots_on,
            failfast=cmd_opts.failfast,
            debug=cmd_opts.debug,
            extended=cmd_opts.extended_tracebacks,
            saucelabs_enabled=cmd_opts.saucelabs_enabled,
            custom_options=cmd_opts.custom
        )
    finally:

        print '--------------------------------------------------------------'
        for desc, cmd in cleanups:
            # Run cleanups, displaying but not propagating exceptions
            try:
                print desc
                cmd()
            except Exception:
                print traceback.format_exc()
def main():
    cmd_opts, args = command.get_opts_run()

    print '--------------------------------------------------------------'
    print 'starting SST...'

    cleanups = []

    if cmd_opts.run_tests:
        cmd_opts.dir_name = 'selftests'
        if not tests.check_devserver_port_used(sst.DEVSERVER_PORT):
            run_django(sst.DEVSERVER_PORT)
            cleanups.append(('\nkilling django...', kill_django,
                             sst.DEVSERVER_PORT))
        else:
            print 'Error: port is in use.'
            print 'can not launch devserver for internal tests.'
            sys.exit(1)

    if cmd_opts.xserver_headless:
        from sst.xvfbdisplay import Xvfb
        print '\nstarting virtual display...'
        display = Xvfb(width=1024, height=768)
        display.start()
        cleanups.append(('\nstopping virtual display...', display.stop))

    if not cmd_opts.quiet:
        print ''
        print '  date time: %s' \
            % datetime.datetime.now().strftime("%Y-%m-%d %H:%M")
        print '  test directory: %r' % cmd_opts.dir_name
        print '  report format: %r' % cmd_opts.report_format
        print '  browser type: %r' % cmd_opts.browser_type
        print '  shared directory: %r' % cmd_opts.shared_modules
        print '  screenshots on error: %r' % cmd_opts.screenshots_on
        print '  failfast: %r' % cmd_opts.failfast
        print '  debug: %r' % cmd_opts.debug
        print '  headless xserver: %r' % cmd_opts.xserver_headless
        print ''

    try:
        command.clear_old_results()
        factory = browsers.browser_factories.get(cmd_opts.browser_type)
        failures = runtests.runtests(
            args,
            test_dir=cmd_opts.dir_name,
            collect_only=cmd_opts.collect_only,
            report_format=cmd_opts.report_format,
            browser_factory=factory(cmd_opts.javascript_disabled),
            shared_directory=cmd_opts.shared_modules,
            screenshots_on=cmd_opts.screenshots_on,
            failfast=cmd_opts.failfast,
            debug=cmd_opts.debug,
            extended=cmd_opts.extended_tracebacks,
            excludes=cmd_opts.excludes
        )
    finally:

        print '--------------------------------------------------------------'
        for cleanup in cleanups:
            # run cleanups, displaying but not propagating exceptions
            desc = cleanup[0]
            cmd = cleanup[1]
            args = cleanup[2:]
            print desc
            try:
                cmd(*args)
            except Exception:
                print traceback.format_exc()

    return failures
Пример #7
0
def main():
    cmd_opts, args = get_opts_run()

    print '----------------------------------------------------------------------'
    print 'starting SST...'

    if cmd_opts.browsermob and cmd_opts.run_tests:
        print 'Warning: can not record local traffic from django testproject'

    if cmd_opts.browsermob:
        browsermob_process = run_browsermob_server(cmd_opts.browsermob)

    if cmd_opts.run_tests:
        cmd_opts.dir_name = 'selftests'
        run_django()

    if cmd_opts.xserver_headless:
        from sst.xvfbdisplay import Xvfb
        print '\nstarting virtual display...'
        display = Xvfb(width=1024, height=768)
        display.start()

    if not cmd_opts.quiet:
        print ''
        print '  date time: %s' % datetime.datetime.now().strftime("%Y-%m-%d %H:%M")
        print '  test directory: %r' % cmd_opts.dir_name
        print '  report format: %r' % cmd_opts.report_format
        print '  browser type: %r' % cmd_opts.browser_type
        print '  javascript disabled: %r' % cmd_opts.javascript_disabled
        print '  browswermob proxy launcher: %r' % cmd_opts.browsermob
        print '  shared directory: %r' % cmd_opts.shared_modules
        print '  screenshots on error: %r' % cmd_opts.screenshots_on
        print '  failfast: %r' % cmd_opts.failfast
        print '  debug: %r' % cmd_opts.debug
        print '  headless xserver: %r' % cmd_opts.xserver_headless
        print ''

    clear_old_results()
    sst.runtests(
        args,
        test_dir=cmd_opts.dir_name,
        report_format=cmd_opts.report_format,
        browser_type=cmd_opts.browser_type,
        javascript_disabled=cmd_opts.javascript_disabled,
        browsermob_enabled=bool(cmd_opts.browsermob),
        shared_directory=cmd_opts.shared_modules,
        screenshots_on=cmd_opts.screenshots_on,
        failfast=cmd_opts.failfast,
        debug=cmd_opts.debug,
        extended=cmd_opts.extended_tracebacks,
    )

    print '----------------------------------------------------------------------'

    if cmd_opts.browsermob:
        print '\nkilling browsermob proxy...'
        browsermob_process.kill()
        browsermob_process.wait()

    if cmd_opts.xserver_headless:
        print '\nstopping virtual display...'
        display.stop()

    if cmd_opts.run_tests:
        print '\nkilling django...'
        kill_django()