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

inbounds not respected during test #2109

Closed
johnnychen94 opened this issue Oct 13, 2020 · 1 comment
Closed

inbounds not respected during test #2109

johnnychen94 opened this issue Oct 13, 2020 · 1 comment

Comments

@johnnychen94
Copy link
Member

johnnychen94 commented Oct 13, 2020

Perhaps this is because test always runs on check-bounds=yes mode?

MWE:

# src/InboundsDemo.jl
module InboundsDemo

export inbounds_test

function f(x)
    x > 1 && throw(ArgumentError("x should be less than 1"))
    return true
end

Base.@propagate_inbounds function inbounds_test(x)
    @boundscheck f(x)
    x + 1
end

end # module
# test/runtest.jl
using InboundsDemo
using Test

@testset "InboundsDemo.jl" begin
    f(x) = @inbounds inbounds_test(x)
    @test f(1) == 2
    @test f(2) == 3
    @test_throws ArgumentError inbounds_test(2)
end
$ julia --startup=no --project=.

(InboundsDemo) pkg> test
    Testing InboundsDemo
Status `/private/var/folders/c0/p23z1x6x3jg_qtqsy_r421y40000gn/T/jl_Um6tnL/Project.toml`
  [432f9513] InboundsDemo v0.1.0 `~/Documents/Julia/InboundsDemo`
  [8dfed614] Test
Status `/private/var/folders/c0/p23z1x6x3jg_qtqsy_r421y40000gn/T/jl_Um6tnL/Manifest.toml`
  [432f9513] InboundsDemo v0.1.0 `~/Documents/Julia/InboundsDemo`
  [2a0f44e3] Base64
  [8ba89e20] Distributed
  [b77e0a4c] InteractiveUtils
  [56ddb016] Logging
  [d6f4376e] Markdown
  [9a3f8284] Random
  [9e88b42a] Serialization
  [6462fe0b] Sockets
  [8dfed614] Test
InboundsDemo.jl: Error During Test at /Users/jc/Documents/Julia/InboundsDemo/test/runtests.jl:7
  Test threw exception
  Expression: f(2) == 3
  ArgumentError: x should be less than 1
  Stacktrace:
   [1] f at /Users/jc/Documents/Julia/InboundsDemo/src/InboundsDemo.jl:6 [inlined]
   [2] inbounds_test at /Users/jc/Documents/Julia/InboundsDemo/src/InboundsDemo.jl:11 [inlined]
   [3] (::var"#f#1")(::Int64) at /Users/jc/Documents/Julia/InboundsDemo/test/runtests.jl:5
   [4] top-level scope at /Users/jc/Documents/Julia/InboundsDemo/test/runtests.jl:7
   [5] top-level scope at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/Test/src/Test.jl:1115
   [6] top-level scope at /Users/jc/Documents/Julia/InboundsDemo/test/runtests.jl:5
  
Test Summary:   | Pass  Error  Total
InboundsDemo.jl |    2      1      3
ERROR: LoadError: Some tests did not pass: 2 passed, 0 failed, 1 errored, 0 broken.
in expression starting at /Users/jc/Documents/Julia/InboundsDemo/test/runtests.jl:4
ERROR: Package InboundsDemo errored during testing

julia> include("test/runtests.jl")
Test Summary:   | Pass  Total
InboundsDemo.jl |    3      3
Test.DefaultTestSet("InboundsDemo.jl", Any[], 3, false)

This makes it a bit hard to test checkbounds behavior, e.g., in JuliaArrays/PaddedViews.jl#40 (comment)

@KristofferC
Copy link
Member

Pkg tests run with --check-bounds=yes. You can start a new process if you want to check that type of optimization behavior.

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

No branches or pull requests

3 participants