Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix nightly docstring test failure #30

Merged
merged 5 commits into from
Aug 9, 2024
Merged

fix nightly docstring test failure #30

merged 5 commits into from
Aug 9, 2024

Conversation

stevengj
Copy link
Member

@stevengj stevengj commented Aug 9, 2024

This hopefully fixes a nightly failure I'm seeing on #29:

 Documentation: Test Failed at /home/runner/work/StructIO.jl/StructIO.jl/test/runtests.jl:167
  Expression: string(#= /home/runner/work/StructIO.jl/StructIO.jl/test/runtests.jl:167 =# @doc(ParametricType)) == "This is a docstring\n"
   Evaluated: "Base.Docs.DocStr(svec(\"This is a docstring\\n\"), nothing, Dict{Symbol, Any}(:typesig => Union{}, :module => Main, :linenumber => 35, :binding => ParametricType, :path => \"/home/runner/work/StructIO.jl/StructIO.jl/test/runtests.jl\", :fields => Dict{Symbol, Any}()))" == "This is a docstring\n"

Apparently, on nightly, @doc foo is returning a DocStr instance, which but string(@doc foo) no longer extracts the underlying string? Something should probably be fixed in Julia itself, but I'm hoping to find a workaround for now.

@stevengj
Copy link
Member Author

stevengj commented Aug 9, 2024

Weird, I can't figure out this test error. I'm able to reproduce it locally when I do import Pkg; Pkg.test("StructIO") on nightly:

julia> import Pkg; Pkg.test("StructIO")
     Testing StructIO
      Status `/private/var/folders/mk/htxc0f3n4z5g0t2qpk5hmvpr0000gn/T/jl_5cDMgp/Project.toml`
  [53d494c1] StructIO v0.3.0 `~/.julia/dev/StructIO`
  [8dfed614] Test v1.11.0
      Status `/private/var/folders/mk/htxc0f3n4z5g0t2qpk5hmvpr0000gn/T/jl_5cDMgp/Manifest.toml`
  [53d494c1] StructIO v0.3.0 `~/.julia/dev/StructIO`
  [2a0f44e3] Base64 v1.11.0
  [b77e0a4c] InteractiveUtils v1.11.0
  [dc6e5ff7] JuliaSyntaxHighlighting v1.12.0
  [56ddb016] Logging v1.11.0
  [d6f4376e] Markdown v1.11.0
  [9a3f8284] Random v1.11.0
  [ea8e919c] SHA v0.7.0
  [9e88b42a] Serialization v1.11.0
  [f489334b] StyledStrings v1.11.0
  [8dfed614] Test v1.11.0
     Testing Running tests...
Test Summary: | Pass  Total  Time
unpack()      |    7      7  0.4s
Test Summary: | Pass  Total  Time
pack()        |   20     20  0.1s
Test Summary:   | Pass  Total  Time
packed_sizeof() |    6      6  0.0s
Documentation: Test Failed at /Users/stevenj/.julia/dev/StructIO/test/runtests.jl:167
  Expression: string(#= /Users/stevenj/.julia/dev/StructIO/test/runtests.jl:167 =# @doc(ParametricType)) == "This is a docstring\n"
   Evaluated: "Base.Docs.DocStr(svec(\"This is a docstring\\n\"), nothing, Dict{Symbol, Any}(:typesig => Union{}, :module => Main, :linenumber => 35, :binding => ParametricType, :path => \"/Users/stevenj/.julia/dev/StructIO/test/runtests.jl\", :fields => Dict{Symbol, Any}()))" == "This is a docstring\n"

Stacktrace:
 [1] top-level scope
   @ ~/.julia/dev/StructIO/test/runtests.jl:167
 [2] macro expansion
   @ ~/Documents/Code/julia/usr/share/julia/stdlib/v1.12/Test/src/Test.jl:1703 [inlined]
 [3] macro expansion
   @ ~/.julia/dev/StructIO/test/runtests.jl:167 [inlined]
 [4] macro expansion
   @ ~/Documents/Code/julia/usr/share/julia/stdlib/v1.12/Test/src/Test.jl:679 [inlined]
Test Summary: | Fail  Total  Time
Documentation |    1      1  3.4s
ERROR: LoadError: Some tests did not pass: 0 passed, 1 failed, 0 errored, 0 broken.
in expression starting at /Users/stevenj/.julia/dev/StructIO/test/runtests.jl:166
ERROR: Package StructIO errored during testing

but if I try to include("runtests.jl") directly it passes:

julia> using StructIO; include(dirname(pathof(StructIO)) * "/../test/runtests.jl")
Test Summary: | Pass  Total  Time
unpack()      |    7      7  0.1s
Test Summary: | Pass  Total  Time
pack()        |   20     20  0.0s
Test Summary:   | Pass  Total  Time
packed_sizeof() |    6      6  0.0s
Test Summary: | Pass  Total  Time
Documentation |    1      1  0.0s
Test.DefaultTestSet("Documentation", Any[], 1, false, false, true, 1.723225727366976e9, 1.723225727367288e9, false, "/Users/stevenj/.julia/dev/StructIO/test/runtests.jl")

Aha, it looks like it's something to do with the REPL, which defines some of the docstring-viewing methods. If I run ./julia /Users/stevenj/.julia/dev/StructIO/test/runtests.jl without the REPL then it errors.

@yuyichao
Copy link

yuyichao commented Aug 9, 2024

Does importing REPL help?

@stevengj
Copy link
Member Author

stevengj commented Aug 9, 2024

Yep, that's what I just committed. It works locally.

@stevengj stevengj merged commit 1b79251 into master Aug 9, 2024
5 checks passed
@stevengj stevengj deleted the stevengj-patch-2 branch August 9, 2024 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants