Skip to content

wookay/Jive.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Jive.jl πŸ‘£

Documentation Build Status (Jive.jl) Build Status (TestJiveRunMoreTests.jl) Coverage

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

runtests

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
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 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.

Refer to the docs/runtests for details.

TestJive.jl is an example package for using Jive. look at also the test/Project.toml file for your own package.

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

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

[compat]
Jive = "0.3"

See TestJiveRunMoreTests.jl to care the advanced cases.

@skip

skip the expression.

using Jive # @skip

@skip println(1+2)

@onlyonce

used to run the block only once.

using Jive # @onlyonce

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

@If

evaluate the module by the condition.

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

Main is the module to evaluate in.

@useinside Main module test_pkgs_flux_optimise
# ...
end

@__END__

throw(Jive.EndError())

using Jive
@__END__

@__REPL__

~/.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

Jive.delete

Make function f uncallable. same for Base.delete_method(only(methods(f, types)))

sprints

  • sprint_plain : get Base.show text/plain output of the x
  • sprint_colored : get Base.show text/plain output of the x with color
  • sprint_html : get Base.show text/html output of the x

See also TestRunner.jl.

About

some useful steps in tests πŸ‘£

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published

Contributors 6

Languages