Skip to content

Broken partialsort test unexpectedly passed in CI job #52591

@jishnub

Description

@jishnub

This is probably a random number issue, as the broken test passes if all the array elements are chosen to be identical. In https://buildkite.com/julialang/julia-master/builds/31349#018c859d-6e20-43d7-bf95-804b688d1ac5,

The global RNG seed was 0x6822a35e4a9f43d3b58013ecc6981379.
Error in testset sorting:
Error During Test at C:\buildkite-agent\builds\win2k22-amdci6-4\julialang\julia-master\julia-f7de26d7ee\share\julia\test\sorting.jl:725
 Unexpected Pass
 Expression: partialsort(1:n, 172, lt = ((i, j)->begin
                    #= C:\buildkite-agent\builds\win2k22-amdci6-4\julialang\julia-master\julia-f7de26d7ee\share\julia\test\sorting.jl:725 =#
                    v[i] <= v[j]
                end)) == perm[172]
 Got correct result, please change to @test if no longer broken.
ERROR: LoadError: Test run finished with errors
in expression starting at C:\buildkite-agent\builds\win2k22-amdci6-4\julialang\julia-master\julia-f7de26d7ee\share\julia\test\runtests.jl:97
[...]
ERROR: A test has failed. Please submit a bug report (https://github.com/JuliaLang/julia/issues)
including error messages above and the output of versioninfo():
Julia Version 1.11.0-DEV.1130
Commit f7de26d7ee (2023-12-20 05:04 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Windows (i686-w64-mingw32)
  CPU: 8 × AMD EPYC Processor (with IBPB)
  WORD_SIZE: 32
  LLVM: libLLVM-15.0.7 (ORCJIT, znver1)
  Threads: 1 on 8 virtual cores
Environment:
  JULIA_BINARYDIST_FILENAME =
  JULIA_CMD_FOR_TESTS = julia-f7de26d7ee/bin/julia.exe .buildkite/utilities/timeout.jl julia-f7de26d7ee/bin/julia.exe
  JULIA_CPU_TARGET = pentium4
  JULIA_CPU_THREADS = 8
  JULIA_IMAGE_THREADS = 8
  JULIA_INSTALL_DIR = julia-f7de26d7ee
  JULIA_NUM_THREADS = 1
  JULIA_SHELL = C:/Program Files/Git/usr/bin/bash
  JULIA_TEST_IS_BASE_CI = true
  JULIA_TEST_MAXRSS_MB = 1536
  JULIA_TEST_VERBOSE_LOGS_DIR = C:\Users\julia\AppData\Local\Temp\jl_a8jqbI
  JULIA_VERSION = 1.11.0-DEV
Stacktrace:
 [1] error(s::String)
   @ Base .\error.jl:35
 [2] runtests(tests::String; ncores::Int32, exit_on_error::Bool, revise::Bool, seed::Nothing)
   @ Base .\util.jl:704
 [3] top-level scope
   @ none:1

The test is at

julia/test/sorting.jl

Lines 706 to 725 in d53fc50

n = 1000
v = rand(1:5, n);
s = sort(v);
# Nevertheless, it still works...
for alg in safe_algs
@test sort(v, alg=alg, lt = <=) == s
end
@test partialsort(v, 172, lt = <=) == s[172]
@test partialsort(v, 315:415, lt = <=) == s[315:415]
# ...and it is consistently reverse stable. All these algorithms swap v[i] and v[j]
# where i < j if and only if lt(o, v[j], v[i]). This invariant holds even for
# this invalid lt order.
perm = reverse(sortperm(v, rev=true))
for alg in safe_algs
@test sort(1:n, alg=alg, lt = (i,j) -> v[i]<=v[j]) == perm
end
# Broken by the introduction of BracketedSort in #52006 which is unstable
@test_broken partialsort(1:n, 172, lt = (i,j) -> v[i]<=v[j]) == perm[172]

Metadata

Metadata

Assignees

No one assigned

    Labels

    sortingPut things in ordertestThis change adds or pertains to unit tests

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions