Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests and fix some issues #14

Merged
merged 5 commits into from
Nov 20, 2016
Merged

Add tests and fix some issues #14

merged 5 commits into from
Nov 20, 2016

Conversation

letientai299
Copy link
Contributor

This is my fisrt step to address #13.
This includes:

  • Test setup with junegunn/vader.
  • Test cases for default usage.
  • Test cases for custom templates.

I also fix 2 issues:

  • Auto append forward slash for g:pydocstring_templates_dir if needed.
  • Remove local script variable s:tmpldir to save some memory.

Le Tien Tai added 5 commits November 18, 2016 14:52
There 2 issues have been addressed:

- If the given g:pydocstring_templates_dir is not ended with a slash
'/', auto append it.

- Reduce the need for one local variable (s:tmpldir) since we always
have to use one variable to store template dir.
@letientai299
Copy link
Contributor Author

Perhaps you also want to enable Travis CI integration, since we now have tests. 😄

@heavenshell
Copy link
Owner

Wow! awsome!! Thank you so much!!
I'll look into it.

Could you add .travis.yml and test job to yml?
I'm not familiar with vader.
I want to run all tests at Travis-CI not local.

@letientai299
Copy link
Contributor Author

I tried integrate with Travis, and fail due to wrong indentation. The tests work just fine with both nvim (0.2.0-dev) and vim (7.4) on my machine (Ubuntu 16.10). But not on Travis (Vim 7.3). I also tried to installl and use nvim on Travis. Still no luck. I don't know why. 😞

To be honest, this is the first time I try vader.

Perhaps, we could skip this integration for later, and focus on #13.

@heavenshell
Copy link
Owner

heavenshell commented Nov 19, 2016

@letientai299
Thank you for working about this!
Travis-CI Vim is too old and it's seems to we need install Vim from GitHub.
I'll try it after your PR merged. But currently I've got errors 😢

I try to run your PR at my local Mac(running macOSX 10.11.6 and MacVim 8.0).

  • Open basic.vader via Terminal.app
$ cd test
$ vim basic.vader
  • Type :Vader
  • Vader run and show error at QuickFix
basic.vader|88 error| class Foo / Put cursor to def foo(self) / Execute Pydocstring on def foo(self) (#23)                                                      
  • Vader shows error
Starting Vader: 1 suite(s), 8 case(s)
  Starting Vader: /path/to/vim-pydocstring/test/basic.vader
    (1/8) [  GIVEN] def foo
    (1/8) [EXECUTE]
    (1/8) [ EXPECT]
    (2/8) [  GIVEN] def foo with 1 param
    (2/8) [EXECUTE]
    (2/8) [ EXPECT]
    (3/8) [  GIVEN] def foo with 2 params
    (3/8) [EXECUTE]
    (3/8) [ EXPECT]
    (4/8) [  GIVEN] def foo with variadic params
    (4/8) [EXECUTE]
    (4/8) [ EXPECT]
    (5/8) [  GIVEN] class Foo
    (5/8) [EXECUTE]
    (5/8) [ EXPECT]
    (6/8) [  GIVEN] class Foo
    (6/8) [     DO] Put cursor to def foo(self)
    (6/8) [   THEN] Execute Pydocstring on def foo(self)
    (6/8) [   THEN] (X) Vim:E492: Not an editor command:   Pydocstring
      > /private/var/folders/wk/wtn88t9559j3zpqj_pwxzzh80000gn/T/vbu2wnr/5, line 1
    (6/8) [ EXPECT] (X)
      - Expected:
            class Foo(object):
                def foo(self):
                    """foo"""
                    pass

                def arg1(self, arg1):
                    pass
      - Got:
          # vim:set et sw=4 ts=4 tw=79:

          # Test def keyword
          #-------------------------------------------------------------------------------
          Given python (def foo):
              def foo():
                  pass

          Execute:
              Pydocstring

          Expect python:
              def foo():
                  """foo"""
                  pass

          Given python (def foo with 1 param):
              def foo(arg):
                  pass

          Execute:
              Pydocstring

          Expect python:
              def foo(arg):
                  """foo

                  :param arg:
                  """
                  pass

          Given python (def foo with 2 params):
              def foo(arg1, arg2):
                  pass

          Execute:
              Pydocstring

          Expect python:
              def foo(arg1, arg2):
                  """foo

                  :param arg1:
                  :param arg2:
                  """
                  pass

          Given python (def foo with variadic params):
              def foo(*arg):
                  pass

          Execute:
              Pydocstring
          Expect python:
              def foo(*arg):
                  """foo

                  :param *arg:
                  """
                  pass


          # Test class keyword
          #-------------------------------------------------------------------------------


          Given python (class Foo):
              class Foo(object):
                  def foo(self):
                      pass

                  def arg1(self, arg1):
                      pass

          Execute:
              Pydocstring

          Expect python:
              class Foo(object):
                  """Foo"""
                  def foo(self):
                      pass

                  def arg1(self, arg1):
                      pass


          Given python (class Foo):
              class Foo(object):
                  def foo(self):
                      pass

                  def arg1(self, arg1):
                      pass

          Do (Put cursor to def foo(self)):
              j

          Then Execute (Execute Pydocstring on def foo(self)):
              Pydocstring

          Expect python:
              class Foo(object):
                  def foo(self):
                      """foo"""
                      pass

                  def arg1(self, arg1):
                      pass


          Given python (class Foo):
              class Foo(object):
                  def foo(self):
                      pass

                  def arg1(self, arg1):
                      pass

          Do (Put cursor to def arg1(self, arg1)):
              4j

          Then Execute (Execute Pydocstring on def arg1(self, arg1)):
              Pydocstring

          Expect python:
              class Foo(object):
                  def foo(self):
                      pass

                  def arg1(self, arg1):
                      """arg1

                      :param arg1:
                      """
                      pass

          # Test aync/await keyword
          #-------------------------------------------------------------------------------
          Given python (async def foo):
              async def foo():
                  pass

          Execute:
              Pydocstring

          Expect python:
              async def foo():
                  """foo"""
                  pass

    (7/8) [  GIVEN] class Foo
    (7/8) [     DO] Put cursor to def arg1(self, arg1)
    (7/8) [   THEN] Execute Pydocstring on def arg1(self, arg1)
    (7/8) [ EXPECT]
    (8/8) [  GIVEN] async def foo
    (8/8) [EXECUTE]
    (8/8) [ EXPECT]
  Success/Total: 7/8
Success/Total: 7/8 (assertions: 0/0)
Elapsed time: 0.224163 sec.

What should I do? I think I miss something 😢

@letientai299
Copy link
Contributor Author

    (6/8) [   THEN] (X) Vim:E492: Not an editor command:   Pydocstring

I think you have not enable Pydocstring on vader. files.
To test Pydocstring isolately, I've created a minimul_vimrc which will source only vader.vim and the plugin. Please try to run the test with:

vim -Nu minimul_vimrc basic.vader

fi

# Open vim with readonly mode just to execute all *.vader tests.
$VIM_EXE -Nu minimal_vimrc -R "+Vader $1"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need ! run Vim and exec Vader command.

-$VIM_EXE -Nu minimal_vimrc -R "+Vader $1"
+$VIM_EXE -Nu minimal_vimrc -R "+Vader! $1"

fi

# Open vim with readonly mode just to execute all *.vader tests.
$VIM_EXE -Nu minimal_vimrc -R '+Vader *.vader'
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-$VIM_EXE -Nu minimal_vimrc -R '+Vader *.vader' 
+$VIM_EXE -Nu minimal_vimrc -R '+Vader! *.vader'

@heavenshell
Copy link
Owner

@letientai299
Thanks, finally I could ran tests.
I requested you to change for run Vader in background.

Copy link
Contributor Author

@letientai299 letientai299 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks ok to me. But I don't know how to merge your change into this PR.

@heavenshell heavenshell merged commit 01ebb67 into heavenshell:master Nov 20, 2016
@heavenshell
Copy link
Owner

@letientai299
Add changes(change run.sh and run-single-test-file.sh) and pushed to Master.
Please pull from master.

Thank you so much to adding test!

@heavenshell
Copy link
Owner

@letientai299
Finally success to run Travis-ci integration.
https://travis-ci.org/heavenshell/vim-pydocstring

I fixed run.sh and test/run-single-test-file.sh for Travis-CI.

@letientai299
Copy link
Contributor Author

Wow, so the trick is build vim itself to get the latest version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants