Beispiel #1
0
    def test_add_verbose_options_with_extras_only(self):
        options = []

        with Options(verbose=2):
            _add_verbose_options(options, '-bogus1', '-bogus2')

        assert options == ['-bogus1', '-bogus2']
Beispiel #2
0
def java_doc(language_config: JavaConfiguration,
             dependencies: List[DependencyPathSet]):
    """
    A function that provides the implementation of the ``doc`` task for the Java
    language.  It will build Java documentation for all the source found in the
    location specified by the Java language configuration.

    :param language_config: the configured Java language information.
    :param dependencies: any configured dependencies on the ``doc`` task.
    """
    code_dir = language_config.code_dir()
    doc_dir = language_config.doc_dir(ensure=True)
    options = ['javadoc']
    packages = []

    if global_options.verbose() == 0:
        options.append('-quiet')
    else:
        _add_verbose_options(options)

    add_class_path(options, dependencies)

    options.extend(['-d', str(doc_dir), '--source-path', str(code_dir)])

    _find_packages(code_dir, code_dir, packages)

    options.extend(packages)

    checked_run(options, 'JavaDoc')
Beispiel #3
0
def _run_describer(classes_dir: Path, paths: Sequence[Path],
                   public_only: bool) -> Sequence[str]:
    """
    A function that wraps the execution of the ``javap`` tool.

    :param classes_dir: the root directory for all the classes we are passing to the
    ``javap`` tool.
    :param paths: the sequence of class files to pass to the ``javap`` tool.  Each must
    be relative to ``classes_dir``.
    :param public_only: controls whether the ``-public`` switch is given to ``javap``.
    :return: the output of the ``javap`` tool, as a sequence of lines.
    """
    # noinspection SpellCheckingInspection
    options = []

    if public_only:
        options.append('-public')

    _add_verbose_options(options)

    for path in paths:
        options.append(str(path))

    # Needs to happen last because of how verbose works.
    options.insert(0, 'javap')

    process = checked_run(options,
                          'Class description',
                          capture=True,
                          cwd=classes_dir)
    lines = process.stdout.decode().split('\n')

    return lines
Beispiel #4
0
    def test_add_verbose_options_no_extras(self):
        options = []

        with Options(verbose=2):
            _add_verbose_options(options)

        assert options == []

        with Options(verbose=3):
            _add_verbose_options(options)

        assert options == ['-verbose']
Beispiel #5
0
    def test_add_verbose_options_inserted_first(self):
        options = ['--flag', 'other-thing']

        with Options(verbose=3):
            _add_verbose_options(options)

        assert options == ['-verbose', '--flag', 'other-thing']

        options = ['--flag', 'other-thing']

        with Options(verbose=3):
            _add_verbose_options(options, '-bogus1', '-bogus2')

        assert options == ['-verbose', '-bogus1', '-bogus2', '--flag', 'other-thing']
Beispiel #6
0
def _build_compiler_options(classes_dir: Path,
                            class_path: List[DependencyPathSet],
                            extra_paths: List[Path] = None) -> List[str]:
    """
    Build a list of the command line options we need to send to the ``javac`` tool.

    :param classes_dir: the path representing the directory into which compile files
    should be written.
    :param class_path: an optional collection of path sets that represent any dependencies
    to include in the class path.
    :param extra_paths: an optional list of extra paths to include in the class path.
    :return: the list of basic options for the ``javac`` command.
    """
    options = ['-d', str(classes_dir)]

    # noinspection SpellCheckingInspection
    _add_verbose_options(options, '-Xdiags:verbose')
    add_class_path(options, class_path, extra_paths)

    return options
Beispiel #7
0
    def test_add_verbose_options_not_verbose_enough(self):
        options = []

        _add_verbose_options(options)

        assert options == []