Beispiel #1
0
    def core_help_option_prints_core_help(self):
        # TODO: change dynamically based on parser contents?
        # e.g. no core args == no [--core-opts],
        # no tasks == no task stuff?
        # NOTE: test will trigger default pty size of 80x24, so the below
        # string is formatted appropriately.
        # TODO: add more unit-y tests for specific behaviors:
        # * fill terminal w/ columns + spacing
        # * line-wrap help text in its own column
        expected = """
Usage: inv[oke] [--core-opts] task1 [--task1-opts] ... taskN [--taskN-opts]

Core options:
  --no-dedupe                      Disable task deduplication.
  -c STRING, --collection=STRING   Specify collection name to load.
  -d, --debug                      Enable debug output.
  -e, --echo                       Echo executed commands before running.
  -f STRING, --config=STRING       Runtime configuration file to use.
  -h [STRING], --help[=STRING]     Show core or per-task help and exit.
  -H STRING, --hide=STRING         Set default value of run()'s 'hide' kwarg.
  -l, --list                       List available tasks.
  -p, --pty                        Use a pty when executing shell commands.
  -r STRING, --root=STRING         Change root directory used for finding task
                                   modules.
  -V, --version                    Show version and exit.
  -w, --warn-only                  Warn, instead of failing, when shell
                                   commands fail.

""".lstrip()
        for flag in ['-h', '--help']:
            _output_eq(flag, expected)
Beispiel #2
0
        def core_help_option_prints_core_help(self):
            # TODO: change dynamically based on parser contents?
            # e.g. no core args == no [--core-opts],
            # no tasks == no task stuff?
            # NOTE: test will trigger default pty size of 80x24, so the below
            # string is formatted appropriately.
            # TODO: add more unit-y tests for specific behaviors:
            # * fill terminal w/ columns + spacing
            # * line-wrap help text in its own column
            expected = """
Usage: inv[oke] [--core-opts] task1 [--task1-opts] ... taskN [--taskN-opts]

Core options:
  --complete                       Print tab-completion candidates for given
                                   parse remainder.
  --no-dedupe                      Disable task deduplication.
  -c STRING, --collection=STRING   Specify collection name to load.
  -d, --debug                      Enable debug output.
  -e, --echo                       Echo executed commands before running.
  -f STRING, --config=STRING       Runtime configuration file to use.
  -h [STRING], --help[=STRING]     Show core or per-task help and exit.
  -H STRING, --hide=STRING         Set default value of run()'s 'hide' kwarg.
  -l, --list                       List available tasks.
  -p, --pty                        Use a pty when executing shell commands.
  -r STRING, --root=STRING         Change root directory used for finding task
                                   modules.
  -V, --version                    Show version and exit.
  -w, --warn-only                  Warn, instead of failing, when shell
                                   commands fail.

""".lstrip()
            for flag in ['-h', '--help']:
                _output_eq(flag, expected)
Beispiel #3
0
        def tasks_dedupe_honors_configuration(self):
            # Kinda-sorta duplicates some tests in executor.py, but eh.
            with cd('configs'):
                # Runtime conf file
                _output_eq(
                    '-c integration -f no-dedupe.yaml biz',
                    """
foo
foo
bar
biz
post1
post2
post2
""".lstrip())
                # Flag beats runtime
                _output_eq(
                    '-c integration -f dedupe.yaml --no-dedupe biz',
                    """
foo
foo
bar
biz
post1
post2
post2
""".lstrip())
Beispiel #4
0
 def missing_default_collection_doesnt_say_None(self):
     with cd('/'):
         _output_eq(
             '-l',
             stderr="Can't find any collection named 'tasks'!\n",
             code=1
         )
Beispiel #5
0
        def chaining_is_depth_first(self):
            _output_eq('-c depth_first deploy', """
Cleaning HTML
Cleaning .tar.gz files
Cleaned everything
Making directories
Building
Deploying
Preparing for testing
Testing
""".lstrip())
Beispiel #6
0
        def chaining_is_depth_first(self):
            _output_eq('-c depth_first deploy', """
Cleaning HTML
Cleaning .tar.gz files
Cleaned everything
Making directories
Building
Deploying
Preparing for testing
Testing
""".lstrip())
Beispiel #7
0
        def per_task_help_works_for_unparameterized_tasks(self):
            expected = """
Usage: inv[oke] [--core-opts] biz [other tasks here ...]

Docstring:
  none

Options:
  none

""".lstrip()
            _output_eq('-c decorator -h biz', expected)
Beispiel #8
0
    def per_task_help_displays_docstrings_if_given(self):
        expected = """
Usage: inv[oke] [--core-opts] foo [other tasks here ...]

Docstring:
  Foo the bar.

Options:
  none

""".lstrip()
        _output_eq('-c decorator -h foo', expected)
Beispiel #9
0
        def per_task_help_displays_docstrings_if_given(self):
            expected = """
Usage: inv[oke] [--core-opts] foo [other tasks here ...]

Docstring:
  Foo the bar.

Options:
  none

""".lstrip()
            _output_eq('-c decorator -h foo', expected)
Beispiel #10
0
    def per_task_help_works_for_unparameterized_tasks(self):
        expected = """
Usage: inv[oke] [--core-opts] biz [other tasks here ...]

Docstring:
  none

Options:
  none

""".lstrip()
        _output_eq('-c decorator -h biz', expected)
Beispiel #11
0
        def per_task_help_prints_help_for_task_only(self):
            expected = """
Usage: inv[oke] [--core-opts] punch [--options] [other tasks here ...]

Docstring:
  none

Options:
  -h STRING, --why=STRING   Motive
  -w STRING, --who=STRING   Who to punch

""".lstrip()
            for flag in ['-h', '--help']:
                _output_eq('-c decorator {0} punch'.format(flag), expected)
Beispiel #12
0
 def simple_output(self):
     expected = self._listing((
         'bar',
         'biz',
         'boz',
         'foo',
         'post1',
         'post2',
         'print_foo',
         'print_name',
         'print_underscored_arg',
     ))
     for flag in ('-l', '--list'):
         _output_eq('-c integration {0}'.format(flag), expected)
Beispiel #13
0
 def simple_output(self):
     expected = self._listing((
         'bar',
         'biz',
         'boz',
         'foo',
         'post1',
         'post2',
         'print_foo',
         'print_name',
         'print_underscored_arg',
     ))
     for flag in ('-l', '--list'):
         _output_eq('-c integration {0}'.format(flag), expected)
Beispiel #14
0
    def per_task_help_prints_help_for_task_only(self):
        expected = """
Usage: inv[oke] [--core-opts] punch [--options] [other tasks here ...]

Docstring:
  none

Options:
  -h STRING, --why=STRING   Motive
  -w STRING, --who=STRING   Who to punch

""".lstrip()
        for flag in ['-h', '--help']:
            _output_eq('-c decorator {0} punch'.format(flag), expected)
Beispiel #15
0
    def per_task_help_dedents_correctly_for_alternate_docstring_style(self):
        expected = """
Usage: inv[oke] [--core-opts] foo3 [other tasks here ...]

Docstring:
  Foo the other bar:

    example code

  Added in 1.1

Options:
  none

""".lstrip()
        _output_eq('-c decorator -h foo3', expected)
Beispiel #16
0
    def per_task_help_dedents_correctly(self):
        expected = """
Usage: inv[oke] [--core-opts] foo2 [other tasks here ...]

Docstring:
  Foo the bar:

    example code

  Added in 1.0

Options:
  none

""".lstrip()
        _output_eq('-c decorator -h foo2', expected)
Beispiel #17
0
        def per_task_help_dedents_correctly_for_alt_docstring_style(self):
            expected = """
Usage: inv[oke] [--core-opts] foo3 [other tasks here ...]

Docstring:
  Foo the other bar:

    example code

  Added in 1.1

Options:
  none

""".lstrip()
            _output_eq('-c decorator -h foo3', expected)
Beispiel #18
0
        def per_task_help_dedents_correctly(self):
            expected = """
Usage: inv[oke] [--core-opts] foo2 [other tasks here ...]

Docstring:
  Foo the bar:

    example code

  Added in 1.0

Options:
  none

""".lstrip()
            _output_eq('-c decorator -h foo2', expected)
Beispiel #19
0
        def tasks_dedupe_honors_configuration(self):
            # Kinda-sorta duplicates some tests in executor.py, but eh.
            with cd('configs'):
                # Runtime conf file
                _output_eq('-c integration -f no-dedupe.yaml biz', """foo
foo
bar
biz
post1
post2
post2
""")
                # Flag beats runtime
                _output_eq('-c integration -f dedupe.yaml --no-dedupe biz',
                           """foo
foo
bar
biz
post1
post2
post2
""")
Beispiel #20
0
 def empty_collections_say_no_tasks(self):
     _output_eq("-c empty -l",
                "No tasks found in collection 'empty'!\n")
Beispiel #21
0
 def missing_default_collection_doesnt_say_None(self):
     os.chdir('/')
     _output_eq('-l', stderr="Can't find any collection named 'tasks'!\n")
Beispiel #22
0
 def version_info(self):
     _output_eq('-V', "Invoke %s\n" % invoke.__version__)
Beispiel #23
0
 def _expect(self, args, expected):
     _output_eq('-c integration {0}'.format(args), expected.lstrip())
Beispiel #24
0
 def version_info(self):
     _output_eq('-V', "Invoke {0}\n".format(invoke.__version__))
Beispiel #25
0
 def prints_return_value_to_stdout_when_on_and_in_collection(self):
     _output_eq("-c autoprint sub.yup", "It's alive!\n")
Beispiel #26
0
 def prints_return_value_to_stdout_when_on_and_in_collection(self):
     _output_eq("-c autoprint sub.yup", "It's alive!\n")
Beispiel #27
0
 def defaults_to_off_and_no_output(self):
     _output_eq("-c autoprint nope", "")
Beispiel #28
0
 def defaults_to_off_and_no_output(self):
     _output_eq("-c autoprint nope", "")
Beispiel #29
0
 def version_info(self):
     _output_eq('-V', "Invoke {0}\n".format(invoke.__version__))
Beispiel #30
0
 def does_not_fire_on_post_tasks(self):
     _output_eq("-c autoprint post_check", "")
Beispiel #31
0
 def _list_eq(self, collection, listing):
     cmd = '-c {0} --list'.format(collection)
     _output_eq(cmd, self._listing(listing))
Beispiel #32
0
 def no_input_means_just_task_names(self):
     _output_eq('-c simple_ns_list --complete', "z_toplevel\na.b.subtask\n")
Beispiel #33
0
 def version_info(self):
     _output_eq('-V', "Invoke %s\n" % invoke.__version__)
Beispiel #34
0
 def underscored_args(self):
     _output_eq(
         '-c integration print_underscored_arg --my-option whatevs',
         "whatevs\n",
     )
Beispiel #35
0
 def args(self):
     _output_eq('-c integration print_name --name inigo', "inigo\n")
Beispiel #36
0
 def prints_return_value_to_stdout_when_on(self):
     _output_eq("-c autoprint yup", "It's alive!\n")
Beispiel #37
0
 def _list_eq(self, collection, listing):
     cmd = '-c {0} --list'.format(collection)
     _output_eq(cmd, self._listing(listing))
Beispiel #38
0
 def underscored_args(self):
     _output_eq(
         '-c integration print_underscored_arg --my-option whatevs',
         "whatevs\n",
     )
Beispiel #39
0
 def empty_collections_say_no_tasks(self):
     _output_eq(
         "-c empty -l",
         "No tasks found in collection 'empty'!\n"
     )
Beispiel #40
0
 def missing_collection_yields_useful_error(self):
     _output_eq('-c huhwhat -l',
                stderr="Can't find any collection named 'huhwhat'!\n",
                code=1)
Beispiel #41
0
 def prints_return_value_to_stdout_when_on(self):
     _output_eq("-c autoprint yup", "It's alive!\n")
Beispiel #42
0
 def missing_default_collection_doesnt_say_None(self):
     with cd('/'):
         _output_eq('-l',
                    stderr="Can't find any collection named 'tasks'!\n",
                    code=1)
Beispiel #43
0
 def does_not_fire_on_post_tasks(self):
     _output_eq("-c autoprint post_check", "")
Beispiel #44
0
 def missing_default_collection_doesnt_say_None(self):
     os.chdir('/')
     _output_eq('-l', stderr="Can't find any collection named 'tasks'!\n")
Beispiel #45
0
 def args(self):
     _output_eq('-c integration print_name --name inigo', "inigo\n")
Beispiel #46
0
 def _expect(self, args, expected):
     _output_eq('-c integration {0}'.format(args), expected.lstrip())
Beispiel #47
0
 def missing_collection_yields_useful_error(self):
     _output_eq(
         '-c huhwhat -l',
         stderr="Can't find any collection named 'huhwhat'!\n",
         code=1
     )
Beispiel #48
0
 def no_input_means_just_task_names(self):
     _output_eq('-c simple_ns_list --complete', "z_toplevel\na.b.subtask\n")
Beispiel #49
0
 def no_input_with_no_tasks_yields_empty_response(self):
     _output_eq('-c empty --complete', "")
Beispiel #50
0
 def no_input_with_no_tasks_yields_empty_response(self):
     _output_eq('-c empty --complete', "")