Skip to content

Commit

Permalink
Remove no longer needed code
Browse files Browse the repository at this point in the history
  • Loading branch information
lgoettgens committed Oct 24, 2023
1 parent 5cb0d2d commit 99bfddb
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 80 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ Aqua.jl provides functions to run a few automatable checks for Julia packages:
(`test/Project.toml`) are consistent.
* Check that all external packages listed in `deps` have corresponding
`compat` entry.
* `Project.toml` formatting is compatible with Pkg.jl output.
* There are no "obvious" type piracies.

See more in the [documentation](https://juliatesting.github.io/Aqua.jl/).
Expand Down
1 change: 0 additions & 1 deletion docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ Aqua.jl provides functions to run a few automatable checks for Julia packages:
(`test/Project.toml`) are consistent.
* Check that all external packages listed in `deps` have corresponding
`compat` entry.
* `Project.toml` formatting is compatible with Pkg.jl output.
* There are no "obvious" type piracies.
* The package does not create any persistent Tasks that might block precompilation of dependencies.

Expand Down
59 changes: 0 additions & 59 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -84,68 +84,9 @@ function checked_repr(obj)
return code
end

const _project_key_order = [
"name",
"uuid",
"keywords",
"license",
"desc",
"deps",
"weakdeps",
"extensions",
"compat",
"extras",
"targets",
]
project_key_order(key::String) =
something(findfirst(x -> x == key, _project_key_order), length(_project_key_order) + 1)

print_project(io, dict) =
TOML.print(io, dict, sorted = true, by = key -> (project_key_order(key), key))

ensure_exception(e::Exception) = e
ensure_exception(x) = ErrorException(string(x))

"""
trydiff(label_a => text_a, label_b => text_b) -> string or exception
"""
function trydiff(
(label_a, text_a)::Pair{<:AbstractString,<:AbstractString},
(label_b, text_b)::Pair{<:AbstractString,<:AbstractString},
)
# TODO: use a pure-Julia function
cmd = `diff --label $label_a --label $label_b -u`
mktemp() do path_a, io_a
print(io_a, text_a)
close(io_a)
mktemp() do path_b, io_b
print(io_b, text_b)
close(io_b)
try
return read(ignorestatus(`$cmd $path_a $path_b`), String)
catch err
return ensure_exception(err)
end
end
end
end

function format_diff(
(label_a, text_a)::Pair{<:AbstractString,<:AbstractString},
(label_b, text_b)::Pair{<:AbstractString,<:AbstractString},
)
diff = trydiff(label_a => text_a, label_b => text_b)
diff isa AbstractString && return diff
# Fallback:
return """
*** $label_a ***
$text_a
*** $label_b ***
$text_b
"""
end

function is_kwcall(signature::DataType)
@static if VERSION < v"1.9"
try
Expand Down
20 changes: 1 addition & 19 deletions test/test_utils.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module TestUtils

using Aqua: askwargs, format_diff
using Aqua: askwargs
using Test

@testset "askwargs" begin
Expand All @@ -10,22 +10,4 @@ using Test
@test askwargs((a = 1,)) === (a = 1,)
end

@testset "format_diff" begin
@testset "normal" begin
if Sys.which("diff") === nothing
@info "Comamnd `diff` not found; skip testing `format_diff`."
else
diff = format_diff("LABEL_A" => "TEXT_A", "LABEL_B" => "TEXT_B")
@test occursin("--- LABEL_A", diff)
@test occursin("+++ LABEL_B", diff)
end
end
@testset "fallback" begin
diff = withenv("PATH" => "/") do
format_diff("LABEL_A" => "TEXT_A", "LABEL_B" => "TEXT_B")
end
@test occursin("*** LABEL_A ***", diff)
end
end

end # module

0 comments on commit 99bfddb

Please sign in to comment.