'Add extra arguments to the commandline.
Args:
test_name: [string] Name of test specifying the options.
args: [dict] Specification of additioanl arguments to pass.
Each key is the name of the argument, the value is the value to pass.
If the value is preceeded with a \'$\' then it refers to the value of
an option. If the value is None then just add the key without an arg.
commandline: [list] The list of command line arguments to append to.'

def add_extra_arguments(self, test_name, args, commandline):

    option_dict = vars(self.options)
    aliases_dict = self.test_suite.get('aliases', {})
    for (key, value) in args.items():
        if isinstance(value, (int, bool)):
            value = str(value)
        if (key == 'alias'):
            for alias_name in value:
                if (not (alias_name in aliases_dict)):
                    raise KeyError('Unknown    alias    "{name}"    referenced    in    args    for    "{test}"'.format(name=alias_name, test=test_name))
                self.add_extra_arguments(test_name, aliases_dict[alias_name], commandline)
            continue
        elif (value is None):
            pass
        elif value.startswith('$'):
            option_name = value[1:]
            if (option_name in option_dict):
                value = (option_dict[option_name] or '""')
            elif (option_name in self.__extra_test_bindings):
                value = (self.__extra_test_bindings[option_name] or '""')
            elif (option_name in os.environ):
                value = os.environ[option_name]
            else:
                raise KeyError('Unknown    option    "{name}"    referenced    in    args    for    "{test}"'.format(name=option_name, test=test_name))
        if (value is None):
            commandline.append(('--' + key))
        else:
            commandline.extend([('--' + key), value])
