# Is there a package that automatically runs tests when files get updated?

**URL:** <https://discourse.julialang.org/t/is-there-a-package-that-automatically-runs-tests-when-files-get-updated/4847>\
**Category:** General Usage\
**Tags:** question\
**Created:** [July 14, 2017, 5:28am UTC](https://discourse.julialang.org/t/is-there-a-package-that-automatically-runs-tests-when-files-get-updated/4847 "2017-07-14T05:28:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![djsegal](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/djsegal/32/13752_2.png) [@djsegal](https://discourse.julialang.org/u/djsegal)\
**Post date:** [July 14, 2017, 5:28am UTC](https://discourse.julialang.org/t/is-there-a-package-that-automatically-runs-tests-when-files-get-updated/4847/1 "2017-07-14T05:28:34Z")

</div>

I started using Revise.jl recently and it got me thinking:

> is there a package that automatically runs tests every time a file gets saved?

This would be similar in nature to:

- ruby’s [guard-rspec](https://github.com/guard/guard-rspec)
- javascript’s [grunt watching](https://github.com/gruntjs/grunt-contrib-watch)

* * *

I think not having to run `Pkg.test("blah")` inside a REPL would make testing 10x more enjoyable

---

<div class="post-metadata">

**Author:** ![djsegal](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/djsegal/32/13752_2.png) [@djsegal](https://discourse.julialang.org/u/djsegal)\
**Post date:** [July 14, 2017, 7:11pm UTC](https://discourse.julialang.org/t/is-there-a-package-that-automatically-runs-tests-when-files-get-updated/4847/2 "2017-07-14T19:11:11Z")

</div>

@tim.holy, not saying you should make it, but do you have any suggestions on how to accomplish this?

// i.e. done w/ minimum reinventing of the wheel

---

<div class="post-metadata">

**Author:** ![tim.holy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tim.holy/32/52_2.png) [@tim.holy](https://discourse.julialang.org/u/tim.holy)\
**Post date:** [July 14, 2017, 7:27pm UTC](https://discourse.julialang.org/t/is-there-a-package-that-automatically-runs-tests-when-files-get-updated/4847/3 "2017-07-14T19:27:07Z")

</div>

It could be done with a fairly modest extension to Revise. You’d want to insert a bit of logic right before [this line](https://github.com/timholy/Revise.jl/blob/d1918056ab54b1e0540cc5ced2f59539cac915f1/src/Revise.jl#L465) to figure out which packages have been modified and then run their tests. Probably the best way to do that is to use the [`file2modules`](https://github.com/timholy/Revise.jl/blob/d1918056ab54b1e0540cc5ced2f59539cac915f1/src/Revise.jl#L257) variable and build up a `Set` of all modified `Module`s. Then you could just have

```julia
for mod in modules
    try
        Pkg.test(string(mod))
    end
end

```

or something. Maybe 10-15 lines of code or so?
