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

Dates/io tests fail on master when networking is unavailable #34655

Open
sostock opened this issue Feb 4, 2020 · 7 comments
Open

Dates/io tests fail on master when networking is unavailable #34655

sostock opened this issue Feb 4, 2020 · 7 comments
Labels
testsystem The unit testing framework and Test stdlib

Comments

@sostock
Copy link
Contributor

sostock commented Feb 4, 2020

When networking is unavailable, some Dates/io tests fail due to the module name not being printed, e.g.:

Error in testset Dates/io:
Test Failed at /home/sebastian/Development/julia/usr/share/julia/stdlib/v1.5/Dates/test/io.jl:10
  Expression: sprint(show, Dates.Date(1, 1, 1)) == "Dates.Date(\"0001-01-01\")"
   Evaluated: "Date(\"0001-01-01\")" == "Dates.Date(\"0001-01-01\")"
Error in testset Dates/io:
Test Failed at /home/sebastian/Development/julia/usr/share/julia/stdlib/v1.5/Dates/test/io.jl:19

This does not happen with a internet connection.

@fredrikekre
Copy link
Member

This just looks like #23806, #29466. I don't see how network access would change the printing.

@sostock
Copy link
Contributor Author

sostock commented Feb 4, 2020

I also don’t see how networking would change the printing. However, Base.runtests prints a warning about skipping some tests (even when I only run the Dates tests). Maybe this affects printing?

julia> Base.runtests("Dates")
┌ Warning: Networking unavailable: Skipping tests [Sockets, LibGit2]
└ @ Main ~/Development/julia/usr/share/julia/test/choosetests.jl:151

@ssikdar1
Copy link
Contributor

ssikdar1 commented Feb 6, 2020

I can create the same problem be with the networking on by comparing the output of
Base.runtests(["Dates/types", "Dates/io"]) and Base.runtests(["Dates/io"])

Running Base.runtests(["Dates/types", "Dates/io"]) everything passes. Running Base.runtests(["Dates/io"]) gives the same type errors @sostock found. Somehow something seems different about show in certain cases.

julia> VERSION
v"1.5.0-DEV.236"

julia> Base.runtests(["Dates/types", "Dates/io"])
Test    (Worker) | Time (s) | GC (s) | GC % | Alloc (MB) | RSS (MB)
Dates/types  (2) |        started at 2020-02-06T10:29:33.04
Dates/io     (3) |        started at 2020-02-06T10:29:33.124
Dates/types  (2) |     1.91 |   0.08 |  4.1 |     218.10 |   251.75
Dates/io     (3) |     9.56 |   0.22 |  2.3 |    1004.87 |   273.75

Test Summary: | Pass  Total
  Overall     |  537    537
    SUCCESS

julia> Base.runtests(["Dates/io"])
Test  (Worker) | Time (s) | GC (s) | GC % | Alloc (MB) | RSS (MB)
Dates/io   (1) |        started at 2020-02-06T10:29:56.574
string/show representation of Date: Test Failed at /Users/ssikdar1/julia/usr/share/julia/stdlib/v1.5/Dates/test/io.jl:10
  Expression: sprint(show, Dates.Date(1, 1, 1)) == "Dates.Date(\"0001-01-01\")"
   Evaluated: "Date(\"0001-01-01\")" == "Dates.Date(\"0001-01-01\")"
Stacktrace:
 [1] top-level scope at /Users/ssikdar1/julia/usr/share/julia/stdlib/v1.5/Dates/test/io.jl:10
 [2] top-level scope at /Users/ssikdar1/julia/usr/share/julia/stdlib/v1.5/Test/src/Test.jl:1114
 [3] top-level scope at /Users/ssikdar1/julia/usr/share/julia/stdlib/v1.5/Dates/test/io.jl:9
string/show representation of Date: Test Failed at /Users/ssikdar1/julia/usr/share/julia/stdlib/v1.5/Dates/test/io.jl:19
  Expression: sprint(show, Dates.DateTime(2000, 1, 1, 0, 0, 0, 1)) == "Dates.DateTime(\"2000-01-01T00:00:00.001\")"
   Evaluated: "DateTime(\"2000-01-01T00:00:00.001\")" == "Dates.DateTime(\"2000-01-01T00:00:00.001\")"
Stacktrace:
 [1] top-level scope at /Users/ssikdar1/julia/usr/share/julia/stdlib/v1.5/Dates/test/io.jl:19
 [2] top-level scope at /Users/ssikdar1/julia/usr/share/julia/stdlib/v1.5/Test/src/Test.jl:1114
 [3] top-level scope at /Users/ssikdar1/julia/usr/share/julia/stdlib/v1.5/Dates/test/io.jl:9
string/show representation of Time: Test Failed at /Users/ssikdar1/julia/usr/share/julia/stdlib/v1.5/Dates/test/io.jl:41
  Expression: sprint(show, t) == shown
   Evaluated: "Time(0)" == "Dates.Time(0)"
Stacktrace:
 [1] macro expansion at /Users/ssikdar1/julia/usr/share/julia/stdlib/v1.5/Dates/test/io.jl:41 [inlined]
 [2] macro expansion at /Users/ssikdar1/julia/usr/share/julia/stdlib/v1.5/Test/src/Test.jl:1114 [inlined]
 [3] top-level scope at /Users/ssikdar1/julia/usr/share/julia/stdlib/v1.5/Dates/test/io.jl:27
string/show representation of Time: Test Failed at /Users/ssikdar1/julia/usr/share/julia/stdlib/v1.5/Dates/test/io.jl:42
  Expression: repr(t) == shown
   Evaluated: "Time(0)" == "Dates.Time(0)"
Stacktrace:
 [1] macro expansion at /Users/ssikdar1/julia/usr/share/julia/stdlib/v1.5/Dates/test/io.jl:42 [inlined]
 [2] macro expansion at /Users/ssikdar1/julia/usr/share/julia/stdlib/v1.5/Test/src/Test.jl:1114 [inlined]
 [3] top-level scope at /Users/ssikdar1/julia/usr/share/julia/stdlib/v1.5/Dates/test/io.jl:27
string/show representation of Time: Test Failed at /Users/ssikdar1/julia/usr/share/julia/stdlib/v1.5/Dates/test/io.jl:41

@ViralBShah ViralBShah added the testsystem The unit testing framework and Test stdlib label Feb 6, 2020
@ssikdar1
Copy link
Contributor

ssikdar1 commented Feb 7, 2020

Seems the issue is here:

julia/test/runtests.jl

Lines 68 to 73 in 4c67921

n = 1
if net_on
n = min(Sys.CPU_THREADS, length(tests))
n > 1 && addprocs_with_testenv(n)
LinearAlgebra.BLAS.set_num_threads(1)
end

Where in the cases where n > 1 Distributed.addproc is being called and the tests pass.
When n = 1 ( the network being turned off => net_on = false and length(tests) = 1 ) addproc isn't called and the tests fail.

I tried a diff like this:

--- a/test/runtests.jl
+++ b/test/runtests.jl
@@ -68,10 +68,13 @@ cd(@__DIR__) do
     n = 1
     if net_on
         n = min(Sys.CPU_THREADS, length(tests))
-        n > 1 && addprocs_with_testenv(n)
+        n >= 1 && addprocs_with_testenv(n)
         LinearAlgebra.BLAS.set_num_threads(1)
+    else
+        addprocs_with_testenv(n)
     end

and both networking off and Base.runtests(["Dates/io"]) passed. But I'm not sure if that's the best solution or not.

@ssikdar1
Copy link
Contributor

ssikdar1 commented Feb 12, 2020

It seems when cff873b was introduced the using Dates
caused situation similar to this:

julia> using Dates

julia> module Foo
       using Dates
       f() = sprint(show, Dates.Date(1, 1, 1))
       end
Main.Foo

julia> Foo.f()
"Date(1, 1, 1)"

Where there are some tests in Dates/test/io.jl using sprint(show...) , for example

https://github.com/JuliaLang/julia/blob/master/stdlib/Dates/test/io.jl#L19

    @test sprint(show, Dates.DateTime(2000, 1, 1, 0, 0, 0, 1)) == "Dates.DateTime(\"2000-01-01T00:00:00.001\")"

that are expecting this behavior:

julia> module Foo
       using Dates
       f() = sprint(show, Dates.Date(1, 1, 1))
       end
Main.Foo

julia> Foo.f()
"Dates.Date(1, 1, 1)"

It works for most test situations because in runtests.jl, addprocs_with_testenv(n) will be
called, which seems to rest the imports? However in cases where n=1, Dates has already been imported causing any tests with sprint(show...) to fail.

@nico202
Copy link
Contributor

nico202 commented Mar 26, 2021

Still happens on v1.6.0

@Zentrik
Copy link
Member

Zentrik commented Apr 21, 2024

runtests(["Dates/io"]) still falls on master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
testsystem The unit testing framework and Test stdlib
Projects
None yet
Development

No branches or pull requests

6 participants