Ejemplo n.º 1
0
def delete(args, update_run_file=True):
    """
    Delete a past run.
    :param args: The run ID to delete
    :param update_run_file: Remove entry from runs.json file
    """
    logger.debug('Received delete command with arguments: %s ' % args)

    if update_run_file:
        # Load run log JSON, find entry that matches the argument and delete it.
        # Then, write new run log file.
        run_file = os.path.join(PathManager.get_working_dir(), 'data', 'runs.json')
        if os.path.exists(run_file):
            logger.debug('Deleting entry %s from run file: %s' % (args, run_file))
            with open(run_file, 'r') as data:
                run_file_data = json.load(data)
            found = False
            for run in run_file_data['runs']:
                if run['id'] == args:
                    run_file_data['runs'].remove(run)
                    found = True
            if found:
                with open(run_file, 'w') as data:
                    json.dump(run_file_data, data, sort_keys=True, indent=True)
            else:
                logger.error('Entry for run %s not found in run log file.' % args)
        else:
            logger.error('Run file not found.')

    # Remove run directory on disk.
    target_run = os.path.join(PathManager.get_working_dir(), 'runs', args)
    if os.path.exists(target_run):
        shutil.rmtree(target_run, ignore_errors=True)
    else:
        logger.debug('Run directory does not exist: %s' % target_run)
Ejemplo n.º 2
0
def save_failed_tests(test_list):
    failed_tests_file = os.path.join(PathManager.get_working_dir(),
                                     'lastfail.txt')
    with open(failed_tests_file, 'w') as f:
        for test in test_list:
            f.write(test + '\n')
    f.close()
Ejemplo n.º 3
0
def get_test_params():
    tests_to_execute = collect_tests()
    pytest_args = []
    if get_core_args().rerun:
        failed_tests_file = os.path.join(PathManager.get_working_dir(),
                                         'lastfail.txt')
        tests_dir = os.path.join(PathManager.get_tests_dir(),
                                 get_core_args().target)
        failed_tests = []
        with open(failed_tests_file, 'r') as f:
            for line in f:
                failed_tests.append(line.rstrip('\n'))
        f.close()
        # Read first line to see if these tests apply to current target.
        if tests_dir in failed_tests[0]:
            pytest_args = failed_tests
        else:
            logging.error(
                'The -a flag cannot be used now because the last failed tests don\'t match current target.'
            )
    else:
        if len(tests_to_execute) > 0:
            for running in tests_to_execute:
                pytest_args.append(running)
        else:
            exit_iris('No tests to execute.', status=1)
    return pytest_args
Ejemplo n.º 4
0
def delete_all():
    """
    Delete each run in the runs.json file, one at a time.
    """
    logger.debug('Delete All command received.')
    run_file = os.path.join(PathManager.get_working_dir(), 'data', 'runs.json')

    with open(run_file, 'r') as data:
        run_file_data = json.load(data)
        data.close()

    for run in run_file_data['runs']:
            delete(run['id'])
Ejemplo n.º 5
0
    def _get_test_candidate(version: str, locale: str) -> str or None:
        """Download and extract a build candidate.

        Build may either refer to a Firefox release identifier, package, or build directory.
        :param: build: str with firefox build
        :return: Installation path for the Firefox App
        """
        logger.debug('Getting build, version %s, locale %s' %
                     (version, locale))
        if version == 'local':
            candidate = PathManager.get_local_firefox_path()
            if candidate is None:
                logger.critical(
                    'Firefox not found. Please download if from https://www.mozilla.org/en-US/firefox/new/'
                )
            return candidate
        elif os.path.isfile(version):
            return version
        else:
            try:
                s_t, s_d = _get_scraper_details(
                    version, CHANNELS,
                    os.path.join(PathManager.get_working_dir(), 'cache'),
                    locale)

                scraper = FactoryScraper(s_t, **s_d)
                firefox_dmg = scraper.download()

                install_dir = install(src=firefox_dmg,
                                      dest=os.path.join(
                                          PathManager.get_temp_dir(),
                                          'firefox{}{}'.format(
                                              normalize_str(version),
                                              normalize_str(locale))))

                return get_binary(install_dir, 'Firefox')
            except errors.NotFoundError:
                logger.critical(
                    'Specified build {} has not been found. Closing Iris ...'.
                    format(version))
        return None