some useful steps in tests 👣


Jive.jl 👣

Documentation Build Status

Jive.jl is a Julia package to help the writing tests.


run the test files in a specific directory and path.

suppose you have some test files in the test/ directory for your package. now let's make your test/runtests.jl with

using Jive


for the runtests.jl, ARGS are used to filter the targets and to set the start offset of the tests.

~/.julia/dev/Jive/test $ julia runtests.jl jive/s start=3
1/4 jive/skip/skip-calls.jl --
2/4 jive/skip/skip-exprs.jl --
3/4 jive/skip/skip-functions.jl
    Pass 4  (0.40 seconds)
4/4 jive/skip/skip-modules.jl
    Pass 4  (0.01 seconds)
✅  All 8 tests have been completed.  (0.62 seconds)

in the above example, test files are matched for only have jive/s and jumping up to the 3rd file.


  • run tests

    ~/.julia/dev/Jive/test $ julia runtests.jl
  • run tests with target directory.

    ~/.julia/dev/Jive/test $ julia runtests.jl jive/If
  • distributed run tests with -p

    ~/.julia/dev/Jive/test $ julia -p3 runtests.jl
  • distributed run tests for Pkg.test(), using JIVE_PROCS ENV.

    ~/.julia/dev/Jive $ JIVE_PROCS=2 julia --project=. -e 'using Pkg; Pkg.test()'

~/.julia/dev/Jive $ julia --project=. -e 'ENV["JIVE_PROCS"]="2"; using Pkg; Pkg.test()'

[TestJive.jl](https://github.com/wookay/TestJive.jl) is an example package for using Jive.
look at also the `Project.toml` file for your own package.

[extras] Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" Jive = "ba5e3d4b-8524-549f-bc71-e76ad9e9deed"

[targets] test = ["Test", "Jive"]

# Watch package folders

You may need to install [Revise.jl](https://github.com/timholy/Revise.jl).

~/.julia/dev/Jive/test/Example/test $ cat runtests.jl using Jive runtests(@DIR, skip=["revise.jl"])

~/.julia/dev/Jive/test/Example/test $ cat revise.jl

julia -i -q --project=.. revise.jl example

using Revise, Jive using Example

trigger = function (path) printstyled("changed ", color=:cyan) println(path) revise() runtests(@DIR, skip=["revise.jl"]) end

watch(trigger, @DIR, sources=[pathof(Example)]) trigger("")

Base.JLOptions().isinteractive==0 && wait()

~/.julia/dev/Jive/test/Example/test $ julia -i -q --project=.. revise.jl example watching folders ...

  • ../src
  • example changed 1/1 example/test1.jl Pass 1 (0.27 seconds) ✅ All 1 test has been completed. (0.55 seconds) ```

when saving any files in the watching folders, it automatically run tests.


skip the expression.

@skip module want_to_skip_this_module sleep(2) end

@skip function want_to_skip_this_function() sleep(2) end

@skip println(1+2)

  - Change to do not skip the code: set `ENV["JIVE_SKIP"] = "0"`

# @onlyonce

used to run the block only once.

* [test/jive/onlyonce](https://github.com/wookay/Jive.jl/tree/master/test/jive/onlyonce)

using Jive # @onlyonce

for _ in 1:10 @onlyonce begin println(42) end @onlyonce(println("hello")) end

# @If

evaluate the module by the condition.

* [test/jive/If](https://github.com/wookay/Jive.jl/blob/master/test/jive/If)

using Jive # @If @If VERSION >= v"1.1.0-DEV.764" module load_some_module end

# @useinside

use inside of the module.

using Jive # @useinside @useinside module test_pkgs_flux_optimise



# `@__END__`


* [`test/jive/__END__`](https://github.com/wookay/Jive.jl/blob/master/test/jive/__END__)

using Jive @END

# `@__REPL__`

* [`test/jive/__REPL__`](https://github.com/wookay/Jive.jl/blob/master/test/jive/__REPL__)
``` html
~/.julia/dev/Jive/test/jive/__REPL__ $ cat test.jl
using Jive

a = 1


@info :a a
~/.julia/dev/Jive/test/jive/__REPL__ $ julia test.jl
julia> a += 2

julia> ^D  # Ctrl + D to exit the REPL
┌ Info: a
└   a = 3

First Commit


Last Touched

4 days ago


171 commits

Used By: