AtelierArith / Replay.jl

Replay your REPL instructions
https://atelierarith.github.io/Replay.jl/dev/
MIT License
36 stars 3 forks source link

Test on Julia nightly (>=1.9) fails #48

Closed terasakisatoshi closed 1 year ago

terasakisatoshi commented 1 year ago
image
terasakisatoshi commented 1 year ago

I could reproduce this issue locally on my mac

               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.10.0-DEV.unknown (2022-11-16)
 _/ |\__'_|_|_|\__'_|  |  Commit ee0f3fc (25 days old master)
|__/                   |

(Replay) pkg> test
     Testing Replay
      Status `/private/var/folders/c_/f7y4cgjx113d8rrq_t63glzh0000gp/T/jl_6gyv45/Project.toml`
  [a8cc5b0e] Crayons v4.1.1
  [dd78c5bf] Replay v0.4.2 `~/work/atelierarith/Replay.jl`
  [44cfe95a] Pkg v1.8.0 `@stdlib/Pkg`
  [6462fe0b] Sockets `@stdlib/Sockets`
  [8dfed614] Test `@stdlib/Test`
      Status `/private/var/folders/c_/f7y4cgjx113d8rrq_t63glzh0000gp/T/jl_6gyv45/Manifest.toml`
  [a8cc5b0e] Crayons v4.1.1
  [dd78c5bf] Replay v0.4.2 `~/work/atelierarith/Replay.jl`
  [0dad84c5] ArgTools v1.1.1 `@stdlib/ArgTools`
  [56f22d72] Artifacts `@stdlib/Artifacts`
  [2a0f44e3] Base64 `@stdlib/Base64`
  [ade2ca70] Dates `@stdlib/Dates`
  [f43a241f] Downloads v1.6.0 `@stdlib/Downloads`
  [7b1f6079] FileWatching `@stdlib/FileWatching`
  [b77e0a4c] InteractiveUtils `@stdlib/InteractiveUtils`
  [b27032c2] LibCURL v0.6.3 `@stdlib/LibCURL`
  [76f85450] LibGit2 `@stdlib/LibGit2`
  [8f399da3] Libdl `@stdlib/Libdl`
  [56ddb016] Logging `@stdlib/Logging`
  [d6f4376e] Markdown `@stdlib/Markdown`
  [ca575930] NetworkOptions v1.2.0 `@stdlib/NetworkOptions`
  [44cfe95a] Pkg v1.8.0 `@stdlib/Pkg`
  [de0858da] Printf `@stdlib/Printf`
  [3fa0cd96] REPL `@stdlib/REPL`
  [9a3f8284] Random `@stdlib/Random`
  [ea8e919c] SHA v0.7.0 `@stdlib/SHA`
  [9e88b42a] Serialization `@stdlib/Serialization`
  [6462fe0b] Sockets `@stdlib/Sockets`
  [fa267f1f] TOML v1.0.3 `@stdlib/TOML`
  [a4e569a6] Tar v1.10.0 `@stdlib/Tar`
  [8dfed614] Test `@stdlib/Test`
  [cf7118a7] UUIDs `@stdlib/UUIDs`
  [4ec0a83e] Unicode `@stdlib/Unicode`
  [deac9b47] LibCURL_jll v7.84.0+0 `@stdlib/LibCURL_jll`
  [29816b5a] LibSSH2_jll v1.10.2+0 `@stdlib/LibSSH2_jll`
  [c8ffd9c3] MbedTLS_jll v2.28.0+0 `@stdlib/MbedTLS_jll`
  [14a3606d] MozillaCACerts_jll v2022.10.11 `@stdlib/MozillaCACerts_jll`
  [83775a58] Zlib_jll v1.2.13+0 `@stdlib/Zlib_jll`
  [8e850ede] nghttp2_jll v1.48.0+0 `@stdlib/nghttp2_jll`
  [3f19e933] p7zip_jll v17.4.0+0 `@stdlib/p7zip_jll`
     Testing Running tests...
replay: color=yes: Test Failed at /Users/atelier/work/atelierarith/Replay.jl/test/runtests.jl:21
  Expression: out == ref
   Evaluated: "\e[?25l\e[?2004h\r\e[0K\e[32m\e[1mjulia> \e[0m\e[0m\r\e[7C\r\e[7Cx = 1 + 1\r\e[0K\e[32m\e[1mjulia> \e[0m\e[0m\r\e[7Cx = 1 + 1\r\e[16C\r\n\e[?2004l\e[0m\e[1m\e[0m\e[0m2\r\n\r\n\r\e[0K\r\e[0K\e[32m\e[1mjulia> \e[0m\e[0m\r\e[7C\r\e[7C\e[?2004h\r\e[0K\e[32m\e[1mjulia> \e[0m\e[0m\r\e[7C\r\e[7Cprintln(\"Hello World\")\r\e[0K\e[32m\e[1mjulia> \e[0m\e[0m\r\e[7Cprintln(\"Hello World\")\r\e[29C\r\n\e[?2004l\e[0mHello World\r\n\r\n\r\e[0K\r\e[0K\e[32m\e[1mjulia> \e[0m\e[0m\r\e[7C\r\e[7C\e[?2004h\r\e[0K\e[32m\e[1mjulia> \e[0m\e[0m\r\e[7C\r\e[7C@show x\r\e[0K\e[32m\e[1mjulia> \e[0m\e[0m\r\e[7C@show x\r\e[14C\r\n\e[?2004l\e[0mx = 2\r\n\e[1m\e[0m\e[0m2\r\n\r\n\r\e[0K\r\e[0K\e[32m\e[1mjulia> \e[0m\e[0m\r\e[7C\r\e[7C\e[?2004h\r\e[0K\e[32m\e[1mjulia> \e[0m\e[0m\r\e[7C\r\e[7Cexit()\r\e[0K\e[32m\e[1mjulia> \e[0m\e[0m\r\e[7Cexit()\r\e[13C\r\n\e[?2004l\e[0m" == "\e[?25l\e[?2004h\r\e[0K\e[32m\e[1mjulia> \e[0m\e[0m\r\e[7C\r\e[7Cx = 1 + 1\r\e[0K\e[32m\e[1mjulia> \e[0m\e[0m\r\e[7Cx = 1 + 1\r\e[16C\r\n\e[?2004l\e[0m\e[0m2\r\n\r\n\r\e[0K\r\e[0K\e[32m\e[1mjulia> \e[0m\e[0m\r\e[7C\r\e[7C\e[?2004h\r\e[0K\e[32m\e[1mjulia> \e[0m\e[0m\r\e[7C\r\e[7Cprintln(\"Hello World\")\r\e[0K\e[32m\e[1mjulia> \e[0m\e[0m\r\e[7Cprintln(\"Hello World\")\r\e[29C\r\n\e[?2004l\e[0mHello World\r\n\r\n\r\e[0K\r\e[0K\e[32m\e[1mjulia> \e[0m\e[0m\r\e[7C\r\e[7C\e[?2004h\r\e[0K\e[32m\e[1mjulia> \e[0m\e[0m\r\e[7C\r\e[7C@show x\r\e[0K\e[32m\e[1mjulia> \e[0m\e[0m\r\e[7C@show x\r\e[14C\r\n\e[?2004l\e[0mx = 2\r\n\e[0m2\r\n\r\n\r\e[0K\r\e[0K\e[32m\e[1mjulia> \e[0m\e[0m\r\e[7C\r\e[7C\e[?2004h\r\e[0K\e[32m\e[1mjulia> \e[0m\e[0m\r\e[7C\r\e[7Cexit()\r\e[0K\e[32m\e[1mjulia> \e[0m\e[0m\r\e[7Cexit()\r\e[13C\r\n\e[?2004l\e[0m"
Stacktrace:
 [1] macro expansion
   @ ~/julia_dev/share/julia/stdlib/v1.10/Test/src/Test.jl:477 [inlined]
 [2] macro expansion
   @ ~/work/atelierarith/Replay.jl/test/runtests.jl:21 [inlined]
 [3] macro expansion
   @ ~/julia_dev/share/julia/stdlib/v1.10/Test/src/Test.jl:1496 [inlined]
 [4] top-level scope
   @ ~/work/atelierarith/Replay.jl/test/runtests.jl:11
Test Summary:     | Fail  Total  Time
replay: color=yes |    1      1  7.2s
ERROR: LoadError: Some tests did not pass: 0 passed, 1 failed, 0 errored, 0 broken.
in expression starting at /Users/atelier/work/atelierarith/Replay.jl/test/runtests.jl:10
ERROR: Package Replay errored during testing

(Replay) pkg
terasakisatoshi commented 1 year ago

It seems REPL package in Julia 1.9 introduced new feature

"Add ability to add output prefixes to the REPL output and use that to implement an IPython mode"

Ref: https://github.com/JuliaLang/julia/pull/46781

LineEdit.jl has the following function that adds \e[1m\e[0m (:bold, :normal)

function write_output_prefix(io::IO, p::Prompt, color::Bool)
    prefix = prompt_string(p.output_prefix_prefix)
    suffix = prompt_string(p.output_prefix_suffix)
    print(io, prefix)
    color && write(io, Base.text_colors[:bold])
    width = write_prompt(io, p.output_prefix, color)
    color && write(io, Base.text_colors[:normal])
    print(io, suffix)
    return width
end

and the display method in REPL.jl calls the function above:

function display(d::REPLDisplay, mime::MIME"text/plain", x)
    x = Ref{Any}(x)
    with_repl_linfo(d.repl) do io
        io = IOContext(io, :limit => true, :module => active_module(d)::Module)
        if d.repl isa LineEditREPL
            mistate = d.repl.mistate
            mode = LineEdit.mode(mistate)
            LineEdit.write_output_prefix(io, mode, get(io, :color, false)::Bool) # <-- HERE
        end
        get(io, :color, false)::Bool && write(io, answer_color(d.repl))
        if isdefined(d.repl, :options) && isdefined(d.repl.options, :iocontext)
            # this can override the :limit property set initially
            io = foldl(IOContext, d.repl.options.iocontext, init=io)
        end
        show(io, mime, x[])
        println(io)
    end
    return nothing
end