Documentation | Build Status |
---|---|
Jive.jl
is a Julia package to help the writing tests.
- โ๏ธ You can make a donation to support this project.
run the test files from the specific directory.
using Jive
runtests(@__DIR__, skip=[], node1=[], targets=ARGS)
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 jive/m start=3
1/5 jive/mockup/mockup.jl --
2/5 jive/skip/skip-calls.jl --
3/5 jive/skip/skip-exprs.jl
Pass 4 (0.38 seconds)
4/5 jive/skip/skip-functions.jl
Pass 4 (0.05 seconds)
5/5 jive/skip/skip-modules.jl
Pass 4 (0.01 seconds)
โ
All 12 tests have been completed. (0.73 seconds)
in the above example, test files are matched for only have jive/s
jive/m
and jumping up to the 3rd file.
- 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()
, usingJIVE_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.
watch the folders. You may need to install 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
using Revise, Jive
using Example
watch(@__DIR__, sources=[pathof(Example)]) do path
@info :changed path
revise()
runtests(@__DIR__, skip=["revise.jl"])
end
# Jive.stop(watch)
~/.julia/dev/Jive/test/Example/test $ julia --project=.. -q -i revise.jl example
watching folders ...
- ../src
- example
when saving any files in the watching folders, it automatically run tests.
skip the expression.
using Jive # @skip
@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"
used to run the block only once.
using Jive # @onlyonce
@onlyonce begin
println(42)
end
evaluate the module by the condition.
using Jive # @If
@If VERSION >= v"1.1.0-DEV.764" module load_some_module
end
use inside of the module.
using Jive # @useinside
@useinside module test_pkgs_flux_optimise
# ...
end
used to produce a replica from the other module.
using Jive # Mock @mockup
using Test
module Goods
struct Foo
end
function f(::Foo)
10
end
function g(::Foo)
10
end
end # module Goods
@mockup module Goods
function f(::Foo)
20
end
end # @mockup module Goods
@test Goods.f(Goods.Foo()) == 10
@test Mock.Goods.f(Mock.Goods.Foo()) == 20
@test Mock.Goods.g(Mock.Goods.Foo()) == 10
Goods3 = @mockup module Goods
function g(::Foo)
30
end
end # @mockup module Goods
@test Goods.f(Goods.Foo()) == 10
@test Mock.Goods.f(Mock.Goods.Foo()) == 10
@test Mock.Goods.g(Mock.Goods.Foo()) == 30
@test Goods3 isa Module
@test Goods3.g === Mock.Goods.g