Giter Club home page Giter Club logo

testenv.jl's Introduction

TestEnv

Code Style: Blue ColPrac: Contributor's Guide on Collaborative Practices for Community Packages

This is a 1-function package: TestEnv.activate. It lets you activate the test environment from a given package.

Why is this useful?

This lets you run code in the test enviroment, interactively; giving you access to all your test-only dependencies. When you run ]test in the REPL, a new Julia process is started which activates a temporary environment containing the tested package together with all its test-only dependencies. These can be either defined in the [extras] section in the package's Project.toml or in a separate test/Project.toml. The special temporary environment is different than the plain package environment (which doesn't contain the extra test dependencies) or the test/Project.toml environment (which doesn't contain the package itself, and may not exist). Once the tests finish, the extra Julia process is closed and the temporary environment is deleted. You are not able to manually run any other code in it, which would be useful for test writing and debugging. Julia does not offer an official mechanism to activate such an environment outside of ]test. That's what TestEnv.activate() is for.

Note on installation:

Like other developer focused tools, TestEnv.jl should not be added as a dependency of the package you are developing, but rather added to your global enviroment, so it is always available. The easiest way to install it to the global enviroment is to start julia (without passing the --project argument), and then run ] add TestEnv.

Example

Consider ChainRules.jl which has a test-only dependency of ChainRulesTestUtils.jl, not a main dependency.

(Note that you can install TestEnv in your global environment as it has no dependencies other than Pkg. This way you can load it from anywhere, instead of having to add it to package environments.)

pkg> activate ~/.julia/dev/ChainRules

julia> using TestEnv;

julia> TestEnv.activate();

julia> using ChainRulesTestUtils

Use Pkg.activate to re-activate the previous environment, e.g. Pkg.activate("~/.julia/dev/ChainRules").

You can also pass in the name of a package, to activate that package and it's test dependencies: TestEnv.activate("Javis") for example would activate Javis.jl's test environment.

Finally you can pass in a function to run in this environment.

using TestEnv, ReTest
TestEnv.activate("Example") do
    retest()
end

See also:

testenv.jl's People

Contributors

oxinabox avatar davidanthoff avatar mmiller-max avatar ericphanson avatar bauglir avatar maxkapur avatar nickrobinson251 avatar kdheepak avatar jackdunnnz avatar jkrumbiegel avatar kimlaberinto avatar kristofferc avatar wikunia avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.