def _parse_variants(self, aliases_str):
        # Use developer defaults if no variant was specified.
        aliases_str = aliases_str or 'dev'
        aliases = aliases_str.split(',')
        user_variants = set(
            reduce(list.__add__,
                   [VARIANT_ALIASES.get(a, [a]) for a in aliases]))

        result = [v for v in ALL_VARIANTS if v in user_variants]
        if len(result) == len(user_variants):
            return result

        for v in user_variants:
            if v not in ALL_VARIANTS:
                print('Unknown variant: %s' % v)
                print('    Available variants: %s' % ALL_VARIANTS)
                print('    Available variant aliases: %s' %
                      VARIANT_ALIASES.keys())
                raise base_runner.TestRunnerError()
        assert False, 'Unreachable'
 def CheckTestMode(name, option):  # pragma: no cover
     if option not in ['run', 'skip', 'dontcare']:
         print('Unknown %s mode %s' % (name, option))
         raise base_runner.TestRunnerError()
    def _process_options(self, options):
        if options.sancov_dir:
            self.sancov_dir = options.sancov_dir
            if not os.path.exists(self.sancov_dir):
                print('sancov-dir %s doesn\'t exist' % self.sancov_dir)
                raise base_runner.TestRunnerError()

        if options.gc_stress:
            options.extra_flags += GC_STRESS_FLAGS

        if options.random_gc_stress:
            options.extra_flags += RANDOM_GC_STRESS_FLAGS

        if self.build_config.asan:
            options.extra_flags.append('--invoke-weak-callbacks')

        if options.novfp3:
            options.extra_flags.append('--noenable-vfp3')

        if options.no_variants:  # pragma: no cover
            print('Option --no-variants is deprecated. '
                  'Pass --variants=default instead.')
            assert not options.variants
            options.variants = 'default'

        if options.exhaustive_variants:  # pragma: no cover
            # TODO(machenbach): Switch infra to --variants=exhaustive after M65.
            print('Option --exhaustive-variants is deprecated. '
                  'Pass --variants=exhaustive instead.')
            # This is used on many bots. It includes a larger set of default
            # variants.
            # Other options for manipulating variants still apply afterwards.
            assert not options.variants
            options.variants = 'exhaustive'

        if options.quickcheck:
            assert not options.variants
            options.variants = 'stress,default'
            options.slow_tests = 'skip'
            options.pass_fail_tests = 'skip'

        if self.build_config.predictable:
            options.variants = 'default'
            options.extra_flags.append('--predictable')
            options.extra_flags.append('--verify-predictable')
            options.extra_flags.append('--no-inline-new')
            # Add predictable wrapper to command prefix.
            options.command_prefix = ([sys.executable, PREDICTABLE_WRAPPER] +
                                      options.command_prefix)

        # TODO(machenbach): Figure out how to test a bigger subset of variants on
        # msan.
        if self.build_config.msan:
            options.variants = 'default'

        if options.variants == 'infra_staging':
            options.variants = 'exhaustive'

        self._variants = self._parse_variants(options.variants)

        def CheckTestMode(name, option):  # pragma: no cover
            if option not in ['run', 'skip', 'dontcare']:
                print('Unknown %s mode %s' % (name, option))
                raise base_runner.TestRunnerError()

        CheckTestMode('slow test', options.slow_tests)
        CheckTestMode('pass|fail test', options.pass_fail_tests)
        if self.build_config.no_i18n:
            base_runner.TEST_MAP['bot_default'].remove('intl')
            base_runner.TEST_MAP['default'].remove('intl')
            # TODO(machenbach): uncomment after infra side lands.
            # base_runner.TEST_MAP['d8_default'].remove('intl')

        if options.time and not options.json_test_results:
            # We retrieve the slowest tests from the JSON output file, so create
            # a temporary output file (which will automatically get deleted on exit)
            # if the user didn't specify one.
            self._temporary_json_output_file = tempfile.NamedTemporaryFile(
                prefix="v8-test-runner-")
            options.json_test_results = self._temporary_json_output_file.name