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

Remove test_project_toml_formatting #209

Merged
merged 3 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- In `test_deps_compat`, the two subtests `check_extras` and `check_weakdeps` are now run by default. ([#202](https://github.com/JuliaTesting/Aqua.jl/pull/202)) [BREAKING]
- `test_deps_compat` now reqiures compat entries for all dependencies. Stdlibs no longer get ignored. This change is motivated by similar changes in the General registry. ([#215](https://github.com/JuliaTesting/Aqua.jl/pull/215)) [BREAKING]

### Removed

- `test_project_toml_formatting` has been removed. Thus, the kwarg `project_toml_formatting` to `test_all` no longer exists. ([#209](https://github.com/JuliaTesting/Aqua.jl/pull/209)) [BREAKING]


## [0.7.4] - 2023-10-24

Expand Down
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
2 changes: 0 additions & 2 deletions 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 Expand Up @@ -84,7 +83,6 @@ using Aqua
project_extras=true,
stale_deps=(ignore=[:SomePackage],),
deps_compat=(ignore=[:SomeOtherPackage],),
project_toml_formatting=true,
piracy=false,
)
end
Expand Down
9 changes: 0 additions & 9 deletions src/Aqua.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ include("exports.jl")
include("project_extras.jl")
include("stale_deps.jl")
include("deps_compat.jl")
include("project_toml_formatting.jl")
include("piracy.jl")
include("persistent_tasks.jl")

Expand All @@ -34,7 +33,6 @@ Run following tests in isolated testset:
* [`test_project_extras(testtarget)`](@ref test_project_extras)
* [`test_stale_deps(testtarget)`](@ref test_stale_deps)
* [`test_deps_compat(testtarget)`](@ref test_deps_compat)
* [`test_project_toml_formatting(testtarget)`](@ref test_project_toml_formatting)
* [`test_piracy(testtarget)`](@ref test_piracy)
* [`test_persistent_tasks(testtarget)`](@ref test_persistent_tasks)

Expand All @@ -50,7 +48,6 @@ passed to `\$x` to specify the keyword arguments for `test_\$x`.
- `project_extras = true`
- `stale_deps = true`
- `deps_compat = true`
- `project_toml_formatting = true`
- `piracy = true`
- `persistent_tasks = true`
"""
Expand All @@ -62,7 +59,6 @@ function test_all(
project_extras = true,
stale_deps = true,
deps_compat = true,
project_toml_formatting = true,
piracy = true,
persistent_tasks = true,
)
Expand Down Expand Up @@ -96,11 +92,6 @@ function test_all(
test_deps_compat(testtarget; askwargs(deps_compat)...)
end
end
@testset "Project.toml formatting" begin
if project_toml_formatting !== false
test_project_toml_formatting(testtarget; askwargs(project_toml_formatting)...)
end
end
@testset "Piracy" begin
if piracy !== false
test_piracy(testtarget; askwargs(piracy)...)
Expand Down
68 changes: 0 additions & 68 deletions src/project_toml_formatting.jl

This file was deleted.

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
81 changes: 0 additions & 81 deletions test/test_project_toml_formatting.jl

This file was deleted.

1 change: 0 additions & 1 deletion test/test_smoke.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ Aqua.test_all(
project_extras = false,
stale_deps = false,
deps_compat = false,
project_toml_formatting = false,
piracy = false,
persistent_tasks = false,
)
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
Loading