Skip to content

Commit

Permalink
Fix _memcmp call for Julia 1.10
Browse files Browse the repository at this point in the history
* This is not exported from Base and the way it is called has
changed.
* Add compat bounds for extras
  Newer versions of Aqua demand this
  More fixes for newer versions of Aqua
* Skip some probably erroneous JET reports
* Disable nightly windows test
  Only JET fails, but we disable all tests, because it's easier.
  This could probably be debugged but I don't have win available.
  And this is taking a long long time.
  • Loading branch information
jlapeyre committed Jan 11, 2024
1 parent 67878f8 commit 6b6c14f
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 9 deletions.
1 change: 1 addition & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:
exclude:
- os: macOS-latest
arch: x86
- os: windows-latest
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
Expand Down
3 changes: 3 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ authors = ["John Lapeyre <[email protected]> and contributors"]
version = "0.1.1"

[compat]
Aqua = ">= 0.8"
JET = ">= 0.0.1"
Test = ">= 0.0"
julia = "1"

[extras]
Expand Down
19 changes: 17 additions & 2 deletions src/FileCmp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,13 @@ function filecmp(io1::IO, io2::IO, _bufsize::Integer=0; info=Val(false), limit::
if limit > 0
remaining -= n
end
# ret = _memcmp(buf1, buf2, n)
ret = Base._memcmp(buf1, buf2, n)
# ret = _memcmp(buf1, buf2, n)
ret = Base._memcmp(memcmparg(buf1), memcmparg(buf2), n)
# if VERSION > v"1.10-"
# ret = Base._memcmp(Base.unsafe_convert(Ptr{UInt8}, buf1), Base.unsafe_convert(Ptr{UInt8}, buf2), n)
# else
# ret = Base._memcmp(buf1, buf2, n)
# end
if ret != 0
! _is_true(info) && return false
n_last = _where_memcmp(buf1, buf2, n)
Expand All @@ -160,6 +165,16 @@ function filecmp(io1::IO, io2::IO, _bufsize::Integer=0; info=Val(false), limit::
return _is_true(info) ? _info : files_equal(_info)
end

function memcmparg(x)
if VERSION > v"1.11-"
return convert(Ptr{UInt8}, x.ref.ptr_or_offset)
elseif VERSION > v"1.10-"
return Base.unsafe_convert(Ptr{UInt8}, x)
else
return x
end
end

_is_true(x::Bool) = x
_is_true(::Val{true}) = true
_is_true(::Val{false}) = false
Expand Down
11 changes: 5 additions & 6 deletions test/aqua_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@ const ThePackage = FileCmp
Aqua.test_deps_compat(ThePackage)
end

# This often gives false positive
@testset "aqua project toml formatting" begin
Aqua.test_project_toml_formatting(ThePackage)
end

@testset "aqua unbound_args" begin
Aqua.test_unbound_args(ThePackage)
end
Expand All @@ -27,7 +22,7 @@ end
end

@testset "aqua piracy" begin
Aqua.test_piracy(ThePackage)
Aqua.test_piracies(ThePackage)
end

@testset "aqua project extras" begin
Expand All @@ -37,3 +32,7 @@ end
@testset "aqua state deps" begin
Aqua.test_stale_deps(ThePackage)
end

@testset "aqua persistent tasks" begin
Aqua.test_persistent_tasks(ThePackage)
end
4 changes: 3 additions & 1 deletion test/jet_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ const package_to_analyze = FileCmp
## the report message. The second is the file it occurs in.
## Not very precise, but ok for now.
const SKIP_MATCHES = [
# ("type Nothing has no field den", "parameters.jl"),
# ("type Nothing has no field den", "parameters.jl"),
# Nested open(path2...) call causes this
("invalid builtin function call", "FileCmp.jl"),
]

## Skip reports for which return true
Expand Down

0 comments on commit 6b6c14f

Please sign in to comment.