Testing changes to stdlib without remaking the whole of Julia

If I make a change in stdlib/, should I make the whole Julia, or is it possible to run the unit tests for the particular library without remaking everything? I could not figure out how.

Revise should be able to revise stdlibs now (using e.g. Revise.track(Random)). So you can Revise and then just include the runtests.jl file from the relevant stdlib.

7 Likes

Is it also possible to use Revise.track(Random) but develop Random in a separate folder and not /path/to/my/julia/share/julia/v1.1/Random/?

I tried @kristoffer.carlsson’s suggestion in Editing a package in stdlib - #5 by kristoffer.carlsson but couldn’t get it to work. The pushfirst! doesn’t seem to have any effect.

If you have the Random stdlib at some other folder you can change its uuid, pkg> develop path/to/Random and then using Random will use that version. This also works with Revise.

4 Likes

Hi, sorry to write on this old subject, I tried to work on Test for issue #31304
I use Pkg> develop ~/workspace/julia/stdlib/Test, write a test that fail then Pkg> test Test is working fine, my test is failing, but when I try to make the test pass, whatever I do on ~/workspace/julia/stdlib/Test/src/Test.jl nothing happens.
I’ve tried to write pushfirst!(LOAD_PATH, "~/workspace/julia/stdlib/") at the beggining of runtest.jl still same result.
How are you developing this particular package ?

You can use Revise, or the method described here: GitHub - JuliaLang/Pkg.jl: Pkg - Package manager for the Julia programming language

Edit: Woops, thought this was a new thread, so this answer is just the same as my (and the other) answers above :slight_smile:

2 Likes

Thanks, with Revise I couldn’t make it works, it works fine with the method described at pkg.jl repo.

this seems to no longer works in 1.6

Why not?

  1. Change UUID

    $ git -C julia diff
    diff --git a/stdlib/Random/Project.toml b/stdlib/Random/Project.toml
    index 6aa9f65374..08fd4dd467 100644
    --- a/stdlib/Random/Project.toml
    +++ b/stdlib/Random/Project.toml
    @@ -1,5 +1,5 @@
     name = "Random"
    -uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
    +uuid = "8a3f8284-a2c9-5f02-9a11-845980a1fd5c"
    
     [deps]
     Serialization = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
    
  2. pkg> dev the package

    $ pkg --project=. dev $PWD/julia/stdlib/Random
       Resolving package versions...
        Updating `/tmp/tmp.aW8QKR3jGS/Project.toml`
      [8a3f8284] + Random v0.0.0 `/tmp/tmp.aW8QKR3jGS/julia/stdlib/Random`
        Updating `/tmp/tmp.aW8QKR3jGS/Manifest.toml`
      [8a3f8284] + Random v0.0.0 `/tmp/tmp.aW8QKR3jGS/julia/stdlib/Random`
    
    1. Load Revise and Random
    julia> using Revise, Random
    
    julia> Random.hello()
    ERROR: UndefVarError: hello not defined
    
  3. Make some changes

    shell> git -C julia diff stdlib/Random/src/
    diff --git a/stdlib/Random/src/Random.jl b/stdlib/Random/src/Random.jl
    index 2cdffd6067..3c38570e15 100644
    --- a/stdlib/Random/src/Random.jl
    +++ b/stdlib/Random/src/Random.jl
    @@ -8,6 +8,8 @@ Support for generating random numbers. Provides [`rand`](@ref), [`randn`](@ref),
     """
     module Random
     
    +hello() = "world"
    +
     include("DSFMT.jl")
     
     using .DSFMT
    
  4. Try again

    julia> Random.hello()
    "world"
    
4 Likes

I missed this part, sorry for the noise this indeed works