Git Product home page Git Product logo

Comments (2)

molovo avatar molovo commented on July 17, 2024 1

This isn't going to happen by v0.6.0. Even the simplified version of coverage I've proposed above is a lot more difficult to implement than I'd anticipated. It's still a feature I'd like to include, but I'm leaving it marked as future, and will hopefully get it included in a future release.

from zunit.

molovo avatar molovo commented on July 17, 2024

Proposal for coverage reporting

Line-by-line coverage simply isn't possible with ZSH, without some sort of extension to record each one of code as it is read and executed. That's simply beyond my ability at the moment, so here I'm proposing a sort of pseudo code coverage, which records coverage of functions rather than individual lines.

We can record the size of the $functions array at the start of testing, and then source all included files (in a subshell so the environment is not affected) and then recount $functions to get the number of functions defined in the project. We can then grep the output of zprof after each test to determine which functions were called by the test, and mark them as covered. Similarly to other languages, to avoid all called functions being marked as covered, we can set which functions are covered within the test. Example syntax:

@test 'My awesome test' {
  @covers _my_awesome_function 

  # test code here...
}

This would only mark _my_awesome_function as covered if it is called, and will not affect coverage of any other function. Similarly, if _my_awesome_function is not called within the test, it will not be marked as covered.

This is a little bit more vague than proper line-level coverage, but it would be fairly easy to implement and is certainly a lot better than anything we've got in ZSH at the moment.

Since coverage would only be performed with an option or if defined in .zunit.yml, I should be able to include this in v0.6.0 without any breaking changes.

One day I might look into developing a proper C extension for ZSH to do line coverage, but I'm not a C developer so it's not something I could do at the moment.

from zunit.

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.