Giter Site home page Giter Site logo

Write important tests about ale HOT 27 CLOSED

dense-analysis avatar dense-analysis commented on July 22, 2024
Write important tests

from ale.

Comments (27)

w0rp avatar w0rp commented on July 22, 2024 1

Thanks to the work of @prashcr and some minor tweaking from yours truly, we now have tests running with a Docker image on Travis CI. The results are speedy, and the output is readable enough. You can see the log from one of the builds here: https://travis-ci.org/w0rp/ale/builds/167205251

If you can get Docker installed on your machine, you can run them locally by running just make. (I was able to set up so make is the same as make test.)

Let's all thank @prashcr for the work he put into this. It's good stuff. 👍

Now we can go about adding some of these tests so they'll actually run on Travis CI. I'll have a look at some of the other pull requests tomorrow, now I've gotten the test suite to run.

from ale.

w0rp avatar w0rp commented on July 22, 2024 1

I was finally able to get a test to run a job. I added a function which checks the job status and waits with sleep in a loop with a timeout to support blocking until linting is complete for the benefit of tests. I didn't add it to the documentation, as I don't intend for the function to be used outside of this plugin.

from ale.

KabbAmine avatar KabbAmine commented on July 22, 2024

And how do we install linters? There are a lot of dependencies involved (pip, npm...). Maybe we should focus first on the ones installable from repositories like gcc and shellcheck?

Take a look at the sh test implemented in validator, its a very simple one and check only if the pattern used in linter handler is valid.

from ale.

w0rp avatar w0rp commented on July 22, 2024

We can install whatever via pip, npm, etc on Travis CI. We could start with just one linter which will cover most of the cases above. Travis CI currently caches pip installed modules, so it shouldn't slow builds down that much.

from ale.

w0rp avatar w0rp commented on July 22, 2024

We could also perhaps make use of virtualenv, but Docker is also being introduced into the mix. Either way, it can be done.

from ale.

KabbAmine avatar KabbAmine commented on July 22, 2024

Good to know, I'm not familiar at all with Docker and Travis.

from ale.

KabbAmine avatar KabbAmine commented on July 22, 2024

Unit test the loclist sorting.

Actually, the loclist is sorted by line numbers, and IMO it should be sorted by severity (Errors first then warnings).

from ale.

w0rp avatar w0rp commented on July 22, 2024

The loclist has to be sorted by line and then column for the binary search used by the cursor functions to work.

from ale.

w0rp avatar w0rp commented on July 22, 2024

The current sorting is also used by the signs functions for showing errors instead of warnings when a line contains both warnings and errors.

from ale.

neersighted avatar neersighted commented on July 22, 2024

Why not just bundle the linters in our docker image?

from ale.

w0rp avatar w0rp commented on July 22, 2024

Yep, whatever programs can be put in the Docker image.

from ale.

w0rp avatar w0rp commented on July 22, 2024

I have started adding tests. This should complement the work from @prashcr on adding the Docker image for running tests on Travis CI. We can start adding tests which pass locally, and get them on Travis CI when that is ready to go.

I managed to catch a bug and fix it in the process, so Vader is looking good to me.

from ale.

w0rp avatar w0rp commented on July 22, 2024

I'll make a note, if anyone can figure out a decent way to get NeoVim included in the build too, then that would be a very good next step.

from ale.

neersighted avatar neersighted commented on July 22, 2024

There is a pending PR on the vim-testbench repo adding neovim support, so I would say wait a few days and then see what they come up with.

from ale.

KabbAmine avatar KabbAmine commented on July 22, 2024

Good job guys, the plugin is far better than before 👍
Sorry for not being available, but I was and still very busy with personal problems (f*****g divorce..).

from ale.

w0rp avatar w0rp commented on July 22, 2024

We'll keep working on it.

I'm sorry to hear about your personal problems! Good luck to you.

from ale.

w0rp avatar w0rp commented on July 22, 2024

Here is something we should keep in mind, which I just fixed, and I've gotten wrong myself. The order of the AssertEqual arguments is expected, actual, and not actual, expected. Only one way produces the correct output when the assertion fails.

from ale.

w0rp avatar w0rp commented on July 22, 2024

I've been trying to get a test to execute a job with buffer input, and so far I haven't succeeded. If anyone finds a way to do that, let me know.

from ale.

w0rp avatar w0rp commented on July 22, 2024

I added an ID to the Makefile so running tests locally will pull a more recent Docker image if we update the ID in the Makefile. So for updating the image, we'll have to do the following.

  1. Update the Dockerfile in the repo, and push that to the master branch. Get the build to run again. (It should be automatic, but so far... it doesn't seem to be.)
  2. Pull the latest Docker image on a local machine, and get the ID for that image.
  3. Update the ID in the Makefile again, and push that to the repo.

If we follow those steps, then anyone who pulls the repo and runs make again afterwards will run the tests with the most up to date image automatically.

from ale.

neersighted avatar neersighted commented on July 22, 2024

Why not just make the Make file run docker pull unconditionally?

from ale.

neersighted avatar neersighted commented on July 22, 2024

I do believe the purpose of the docker images -q was just to print the image version to the test output -- there is no reason not to pull every time.

from ale.

w0rp avatar w0rp commented on July 22, 2024

I believe that will mean running make will always use your Internet connection.

from ale.

neersighted avatar neersighted commented on July 22, 2024

If you have the latest image it will just noop, and if you don't have internet it will just error and continue.

from ale.

w0rp avatar w0rp commented on July 22, 2024

Hmm, I'll have to try it with my Internet connection turned off later. As long as it runs quickly enough, I'll go with that.

from ale.

w0rp avatar w0rp commented on July 22, 2024

I tried running docker pull with my Internet connection off, and the command fails. I could just ignore the error, but then that will cause other weird errors.

from ale.

w0rp avatar w0rp commented on July 22, 2024

I tried to find a way to test the cursor moving triggering the function, but I couldn't get it to work.

from ale.

w0rp avatar w0rp commented on July 22, 2024

I tried last night, but I had trouble testing anything around functions triggered from autocmd events. I'll close this issue now, and open another asking for help.

from ale.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.