# Testing multiple packages in a batch

**URL:** <https://discourse.julialang.org/t/testing-multiple-packages-in-a-batch/28756>\
**Category:** General Usage\
**Created:** [September 14, 2019, 11:58am UTC](https://discourse.julialang.org/t/testing-multiple-packages-in-a-batch/28756 "2019-09-14T11:58:37Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [September 14, 2019, 11:58am UTC](https://discourse.julialang.org/t/testing-multiple-packages-in-a-batch/28756/1 "2019-09-14T11:58:38Z")

</div>

I have multiple packages that I would like to test more or less automatically.  
For an arbitrary one of these I would clone it, start Julia, and do:

```julia
cd("Package path")
using Pkg                                            
Pkg.activate(".")                                    
Pkg.test()

```

I have a suspicion that if I try to do this in a continuously running Julia session, processing an array of packages, it would not be the same as doing the above. In particular, I think that I would have to do `dev` to “clone” the package, and therefore the running Julia session would have some memory of the packages tested previously. Isn’t that right?

So I suppose a solution would be to process the list of packages in a loop, and fire up a fresh instance of a Julia process to run the test. Has anyone written a tool that would do this yet?

---

<div class="post-metadata">

**Author:** ![anon92994695](https://avatars.discourse-cdn.com/v4/letter/a/ce7236/32.png) [@anon92994695](https://discourse.julialang.org/u/anon92994695)\
**Post date:** [September 14, 2019, 12:02pm UTC](https://discourse.julialang.org/t/testing-multiple-packages-in-a-batch/28756/2 "2019-09-14T12:02:37Z")

</div>

I could be wrong but can’t you do the following,

```julia
cd("Package path")
using Pkg                                            
Pkg.activate(".")                                    
Pkg.test()
Pkg.activate() #deactivate package

cd("Package path #2")                                            
Pkg.activate(".")                                    
Pkg.test()
Pkg.activate() #deactivate package

```

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [September 14, 2019, 12:04pm UTC](https://discourse.julialang.org/t/testing-multiple-packages-in-a-batch/28756/3 "2019-09-14T12:04:47Z")

</div>

I think you might be onto something. Perhaps the activation will wipe the slate clean.

---

<div class="post-metadata">

**Author:** ![anon92994695](https://avatars.discourse-cdn.com/v4/letter/a/ce7236/32.png) [@anon92994695](https://discourse.julialang.org/u/anon92994695)\
**Post date:** [September 14, 2019, 12:07pm UTC](https://discourse.julialang.org/t/testing-multiple-packages-in-a-batch/28756/4 "2019-09-14T12:07:22Z")

</div>

I think that’s how it works in a REPL not sure how it’d go in a Julia script or interactive session. Give it a try though - that’d be a quick fix if that’s what you want.

---

<div class="post-metadata">

**Author:** ![hendri54](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hendri54/32/9621_2.png) [@hendri54](https://discourse.julialang.org/u/hendri54)\
**Post date:** [September 14, 2019, 12:09pm UTC](https://discourse.julialang.org/t/testing-multiple-packages-in-a-batch/28756/5 "2019-09-14T12:09:01Z")

</div>

This should work because `test` creates a temporary environment. From the [Pkg docs](https://julialang.github.io/Pkg.jl/v1/api/#Pkg.test):

> The tests are run by generating a temporary environment with only `pkg` and its (recursive) dependencies in it.

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [September 14, 2019, 12:41pm UTC](https://discourse.julialang.org/t/testing-multiple-packages-in-a-batch/28756/6 "2019-09-14T12:41:58Z")

</div>

> [@PetrKryslUCSD](#):
>
> the running Julia session would have some memory of the packages tested previously. Isn’t that right?

I am not sure what you mean here, the REPL history would contain previous commands, but otherwise each `Pkg.test` creates its own temporary environment _and_ a fresh process. See `?Pkg.test`.

The loop could save the startup cost of the outer process, but otherwise test runs are pretty well isolated.

> [@PetrKryslUCSD](#):
>
> Has anyone written a tool that would do this yet?

I think the key question is what you want to _do_ with the results. Just report a bunch of flags for failure/success, keep the logs, etc.

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [September 14, 2019, 1:15pm UTC](https://discourse.julialang.org/t/testing-multiple-packages-in-a-batch/28756/7 "2019-09-14T13:15:20Z")

</div>

This seems to work: [https://github.com/PetrKryslUCSD/FinEtoolsTestAll.jl/blob/master/testall.jl](https://github.com/PetrKryslUCSD/FinEtoolsTestAll.jl/blob/master/testall.jl)
