dummy-link

Jive

some useful steps in tests 👣

Readme

Jive.jl 👣

Documentation Build Status

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

runtests

run the test files in a specific directory and path.

using Jive
runtests(@__DIR__)

runtests.svg

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 --color=yes 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.37 seconds)
4/4 jive/skip/skip-modules.jl
    Pass 4  (0.01 seconds)
✅   All 8 tests have been completed.  (0.65 seconds)

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

Examples

  • run tests

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

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

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

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

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


see also [travis job logs](https://travis-ci.org/wookay/Jive.jl/jobs/483203342#L452) and [TestJive.jl](https://github.com/wookay/TestJive.jl).


# 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 --color=yes --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 --color=yes --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

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



# `@__END__`

`throw(Jive.EndError())`

* [`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

@__REPL__

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

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

First Commit

10/17/2018

Last Touched

21 days ago

Commits

127 commits

Used By: