Exemplo n.º 1
0
 def test_option_name(self):
     test_cases = [
         sut.OptionName('s'),
         sut.OptionName('long'),
         sut.OptionName(long_name='long'),
     ]
     for value in test_cases:
         with self.subTest():
             str(value)
Exemplo n.º 2
0
 def elements(self) -> List:
     return [
         file_check_properties.DIR_CONTENTS,
         OptionArgument(file_or_dir_contents.RECURSIVE_OPTION.name),
         OptionArgument(a.OptionName(self.invalid_option_name)),
         SymbolReference('valid_files_matcher_arg'),
     ]
Exemplo n.º 3
0
RELATIVITY_DESCRIPTION_HDS_ACT = 'act-home directory'
RELATIVITY_DESCRIPTION_CWD = 'current directory'
RELATIVITY_DESCRIPTION_ACT = 'act directory'
RELATIVITY_DESCRIPTION_TMP = 'tmp directory'
RELATIVITY_DESCRIPTION_RESULT = 'result directory'

RELATIVITY_DESCRIPTION_SYMBOL = 'value of path symbol'
RELATIVITY_DESCRIPTION_SOURCE_FILE = 'location of the current source file'

EXACTLY_DIR__REL_HDS_CASE = 'EXACTLY_HOME'
EXACTLY_DIR__REL_HDS_ACT = 'EXACTLY_ACT_HOME'
EXACTLY_DIR__REL_ACT = 'EXACTLY_ACT'
EXACTLY_DIR__REL_TMP = 'EXACTLY_TMP'
EXACTLY_DIR__REL_RESULT = 'EXACTLY_RESULT'

REL_TMP_OPTION_NAME = argument.OptionName(long_name='rel-tmp')
REL_ACT_OPTION_NAME = argument.OptionName(long_name='rel-act')
REL_RESULT_OPTION_NAME = argument.OptionName(long_name='rel-result')
REL_CWD_OPTION_NAME = argument.OptionName(long_name='rel-cd')
REL_HDS_CASE_OPTION_NAME = argument.OptionName(long_name='rel-home')
REL_HDS_ACT_OPTION_NAME = argument.OptionName(long_name='rel-act-home')
REL_SYMBOL_OPTION_NAME = argument.OptionName(long_name='rel')
REL_SOURCE_FILE_DIR_OPTION_NAME = argument.OptionName('rel-here')

REL_TMP_OPTION = long_option_syntax(REL_TMP_OPTION_NAME.long)
REL_ACT_OPTION = long_option_syntax(REL_ACT_OPTION_NAME.long)
REL_RESULT_OPTION = long_option_syntax(REL_RESULT_OPTION_NAME.long)
REL_CWD_OPTION = long_option_syntax(REL_CWD_OPTION_NAME.long)
REL_HDS_CASE_OPTION = long_option_syntax(REL_HDS_CASE_OPTION_NAME.long)
REL_HDS_ACT_OPTION = long_option_syntax(REL_HDS_ACT_OPTION_NAME.long)
REL_symbol_OPTION = long_option_syntax(REL_SYMBOL_OPTION_NAME.long)
Exemplo n.º 4
0
 def test_option(self):
     self._check(sut.Option(sut.OptionName('n')), sut.Option)
Exemplo n.º 5
0
 def test_option(self):
     value = sut.Option(sut.OptionName('s'), 'argument')
     str(value)
Exemplo n.º 6
0
from exactly_lib.util.cli_syntax.elements import argument as a
from . import matcher

WHOLE_PATH_MATCHER_NAME = 'path'
NAME_MATCHER_NAME = 'name'
STEM_MATCHER_NAME = 'stem'
SUFFIXES_MATCHER_NAME = 'suffixes'
SUFFIX_MATCHER_NAME = 'suffix'
TYPE_MATCHER_NAME = 'type'
PROGRAM_MATCHER_NAME = matcher.RUN_PROGRAM

PROGRAM_ARG_OPTION__LAST = a.Option(a.OptionName('path-arg-last'))
PROGRAM_ARG_OPTION__MARKER = a.Option(a.OptionName('path-arg-marker'),
                                      'MARKER')
Exemplo n.º 7
0
from exactly_lib.symbol.sdv_structure import SymbolReference
from exactly_lib.tcfs.hds import HomeDs
from exactly_lib.tcfs.path_relativity import DirectoryStructurePartition
from exactly_lib.tcfs.tcds import TestCaseDs
from exactly_lib.type_val_deps.dep_variants.ddv.ddv_validation import DdvValidator
from exactly_lib.type_val_deps.types.string_.string_ddv import StringDdv
from exactly_lib.type_val_deps.types.string_.string_sdv import StringSdv
from exactly_lib.util.cli_syntax import option_syntax
from exactly_lib.util.cli_syntax.elements import argument as a
from exactly_lib.util.description_tree import details
from exactly_lib.util.description_tree.renderer import DetailsRenderer
from exactly_lib.util.render import strings as string_rendering
from exactly_lib.util.str_ import str_constructor
from exactly_lib.util.symbol_table import SymbolTable

IGNORE_CASE_OPTION_NAME = a.OptionName(long_name='ignore-case')

IGNORE_CASE_OPTION = option_syntax.option_syntax(IGNORE_CASE_OPTION_NAME)


class ParserOfRegex(ParserFromTokenParserBase[RegexSdv]):
    def __init__(self):
        super().__init__(False, False)
        self._string_parser = parse_rich_string.RichStringParser()

    def parse_from_token_parser(self, token_parser: TokenParser) -> RegexSdv:
        token_parser.require_has_valid_head_token(
            syntax_elements.REGEX_SYNTAX_ELEMENT.singular_name)
        is_ignore_case = token_parser.consume_and_handle_optional_option(
            False, lambda x: True, IGNORE_CASE_OPTION_NAME)
        regex_pattern = self._string_parser.parse_from_token_parser(
Exemplo n.º 8
0
from exactly_lib.definitions.primitives import program, string_transformer
from exactly_lib.definitions.test_case.instructions import instruction_names
from exactly_lib.impls.types.string_ import syntax_elements as string_se
from exactly_lib.type_val_deps.types.path import path_relativities
from exactly_lib.util.cli_syntax.elements import argument
from exactly_lib.util.cli_syntax.elements import argument as a
from exactly_lib.util.cli_syntax.option_syntax import long_option_syntax

SHELL_COMMAND_TOKEN = program.SHELL_COMMAND_TOKEN
SYSTEM_PROGRAM_TOKEN = program.SYSTEM_PROGRAM_TOKEN

SYMBOL_REF_PROGRAM_TOKEN = instruction_names.SYMBOL_REF_PROGRAM_INSTRUCTION_NAME

EXE_FILE_REL_OPTION_ARG_CONF = path_relativities.ALL_REL_OPTIONS_ARG_CONFIG

PYTHON_EXECUTABLE_OPTION_NAME = argument.OptionName(long_name='python')
PYTHON_EXECUTABLE_OPTION_STRING = long_option_syntax(
    PYTHON_EXECUTABLE_OPTION_NAME.long)

REMAINING_PART_OF_CURRENT_LINE_AS_LITERAL_MARKER = string_se.TEXT_UNTIL_EOL_MARKER

EXISTING_FILE_OPTION_NAME = a.OptionName(long_name='existing-file')
EXISTING_DIR_OPTION_NAME = a.OptionName(long_name='existing-dir')
EXISTING_PATH_OPTION_NAME = a.OptionName(long_name='existing-path')

ARGUMENT_SYNTAX_ELEMENT_NAME = a.Named('ARGUMENT')

WITH_TRANSFORMED_CONTENTS_OPTION_NAME = string_transformer.WITH_TRANSFORMED_CONTENTS_OPTION_NAME

STDIN_OPTION_NAME = a.OptionName(long_name='stdin')
Exemplo n.º 9
0
from exactly_lib.definitions import logic
from exactly_lib.definitions.primitives import str_matcher, matcher
from exactly_lib.definitions.primitives.file_or_dir_contents import EMPTINESS_CHECK_ARGUMENT
from exactly_lib.util.cli_syntax.elements import argument as a

NOT_ARGUMENT = logic.NOT_OPERATOR_NAME
EMPTY_ARGUMENT = EMPTINESS_CHECK_ARGUMENT
EQUALS_ARGUMENT = 'equals'
EQUALS_ARGUMENT__ALTERNATIVE = '=='
MATCHES_ARGUMENT = str_matcher.MATCH_REGEX_ARGUMENT
MATCHES_ARGUMENT__ALTERNATIVE = str_matcher.MATCH_REGEX_ARGUMENT__SHORT
RUN_PROGRAM_ARGUMENT = matcher.RUN_PROGRAM

FULL_MATCH_ARGUMENT_OPTION = a.OptionName(long_name='full')

NUM_LINES_ARGUMENT = 'num-lines'

LINE_ARGUMENT = 'line'

NUM_LINES_DESCRIPTION = 'number of lines'
Exemplo n.º 10
0
from exactly_lib.definitions.entity import types
from exactly_lib.util.cli_syntax import option_syntax
from exactly_lib.util.cli_syntax.elements import argument as a
from . import program
from ..test_case import reserved_words

IDENTITY_TRANSFORMER_NAME = 'identity'
SEQUENCE_OPERATOR_NAME = reserved_words.PIPE
RUN_PROGRAM = program.RUN_PROGRAM_PRIMITIVE

STRING_TRANSFORMER_ARGUMENT = a.Named(types.STRING_TRANSFORMER_TYPE_INFO.syntax_element_name)

STRING_TRANSFORMATION_ARGUMENT = a.Named('TRANSFORMATION')

WITH_TRANSFORMED_CONTENTS_OPTION_NAME = a.OptionName(long_name='transformed-by')

WITH_TRANSFORMED_CONTENTS_OPTION = option_syntax.option_syntax(WITH_TRANSFORMED_CONTENTS_OPTION_NAME)

TRANSFORMATION_OPTION = a.Option(WITH_TRANSFORMED_CONTENTS_OPTION_NAME,
                                 argument=types.STRING_TRANSFORMER_TYPE_INFO.syntax_element_name)

WITH_IGNORED_EXIT_CODE_OPTION_NAME = program.WITH_IGNORED_EXIT_CODE_OPTION_NAME
Exemplo n.º 11
0
from exactly_lib.definitions.primitives import program as program_primitives
from exactly_lib.impls.instructions import source_file_relativities
from exactly_lib.tcfs.path_relativity import RelOptionType
from exactly_lib.type_val_deps.types.path.rel_opts_configuration import RelOptionArgumentConfiguration
from exactly_lib.util.cli_syntax.elements import argument as a
from exactly_lib.util.process_execution.process_output_files import ProcOutputFile

PROGRAM_OUTPUT_OPTIONS = {
    ProcOutputFile.STDOUT: a.OptionName('stdout-from'),
    ProcOutputFile.STDERR: a.OptionName('stderr-from'),
}
FILE_OPTION = a.OptionName('contents-of')
IGNORE_EXIT_CODE = program_primitives.WITH_IGNORED_EXIT_CODE_OPTION_NAME

SOURCE_FILE_ARGUMENT_NAME = a.Named('SOURCE-FILE-PATH')


def src_rel_opt_arg_conf_for_phase(
    phase_is_after_act: bool,
    default_relativity: RelOptionType = RelOptionType.REL_HDS_CASE,
) -> RelOptionArgumentConfiguration:
    return source_file_relativities.src_rel_opt_arg_conf_for_phase(
        default_relativity,
        SOURCE_FILE_ARGUMENT_NAME.name,
        phase_is_after_act,
    )
Exemplo n.º 12
0
 def runTest(self):
     with self.assertRaises(SingleInstructionInvalidArgumentException):
         integration_check.CHECKER__PARSE_FULL.parser.parse(
             fm_args.InvalidDirContents(
                 OptionArgument(
                     a.OptionName('invalid-option'))).as_remaining_source)
Exemplo n.º 13
0
from exactly_lib.util.cli_syntax.elements import argument as a

OUTPUT_FROM_PROGRAM_OPTION_NAME = a.OptionName(long_name='from')
Exemplo n.º 14
0
from exactly_lib.util.cli_syntax import option_syntax
from exactly_lib.util.cli_syntax.elements import argument as a

SHELL_COMMAND_TOKEN = '$'
SYSTEM_PROGRAM_TOKEN = '%'
SYMBOL_PROGRAM_TOKEN = '@'

RUN_PROGRAM_PRIMITIVE = 'run'

STDIN_OPTION_NAME = a.OptionName(long_name='stdin')
STDIN_OPTION_STR = option_syntax.option_syntax(STDIN_OPTION_NAME)

WITH_IGNORED_EXIT_CODE_OPTION_NAME = a.OptionName(long_name='ignore-exit-code')
Exemplo n.º 15
0
from exactly_lib.definitions import instruction_arguments, logic
from exactly_lib.util.cli_syntax.elements import argument as a

UNSET_IDENTIFIER = 'unset'
ASSIGNMENT_IDENTIFIER = instruction_arguments.ASSIGNMENT_OPERATOR
VAR_NAME_ELEMENT = 'NAME'
VAR_VALUE_ELEMENT = 'VALUE'
PHASE_SPEC_ELEMENT = 'PHASE-SPEC'

PHASE_SPEC__OPTION_NAME = a.OptionName('of')

PHASE_SPEC__ACT = 'act'
PHASE_SPEC__NON_ACT = logic.NOT_OPERATOR_NAME + PHASE_SPEC__ACT
Exemplo n.º 16
0
from exactly_lib.definitions.entity import syntax_elements
from exactly_lib.definitions.primitives import program, string_transformer
from exactly_lib.util.cli_syntax.elements import argument as a

IDENTITY_TRANSFORMER_NAME = string_transformer.IDENTITY_TRANSFORMER_NAME
SEQUENCE_OPERATOR_NAME = string_transformer.SEQUENCE_OPERATOR_NAME
RUN_PROGRAM_TRANSFORMER_NAME = string_transformer.RUN_PROGRAM

RUN_WITH_IGNORED_EXIT_CODE_OPTION_NAME = program.WITH_IGNORED_EXIT_CODE_OPTION_NAME

REPLACE_TRANSFORMER_NAME = 'replace'
FILTER_TRANSFORMER_NAME = 'filter'
GREP_TRANSFORMER_NAME = 'grep'

RANGE_EXPR_SED_NAME = 'LINE-NUMBER-RANGE'
LINE_NUMBERS_FILTER_OPTION = a.Option(a.OptionName('line-nums'))

LINE_NUMBERS_FILTER__LIMIT_SEPARATOR = ':'

CHARACTER_CASE = 'char-case'
CHARACTER_CASE_TO_LOWER_OPTION_NAME = a.OptionName(long_name='to-lower')
CHARACTER_CASE_TO_UPPER_OPTION_NAME = a.OptionName(long_name='to-upper')

STRIP_SPACE = 'strip'
STRIP_TRAILING_SPACE_OPTION_NAME = a.OptionName(long_name='trailing-space')
STRIP_TRAILING_NEW_LINES_OPTION_NAME = a.OptionName(
    long_name='trailing-new-lines')

TCDS_PATH_REPLACEMENT = 'replace-test-case-dirs'

LINES_SELECTION_OPTION_NAME = a.OptionName(long_name='at')