Skip to content

Commit

Permalink
Skip Project formatting if VERSION < 1.7 and there are weakdeps
Browse files Browse the repository at this point in the history
  • Loading branch information
gdalle committed Oct 12, 2023
1 parent 19a5588 commit d2d62f8
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/project_toml_formatting.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,13 @@ function _analyze_project_toml_formatting_2(path::AbstractString, original)

prj = TOML.parse(original)
formatted = sprint(print_project, prj)
if splitlines(original) == splitlines(formatted)
if VERSION < v"1.7" && (haskey(prj, "weakdeps") || haskey(prj, "extensions"))
LazyTestResult(
label,
"The file `$(path)` has not been tested because it has weak dependencies and Julia is in version $VERSION < 1.7.",
true,
)
elseif splitlines(original) == splitlines(formatted)
LazyTestResult(label, "The file `$(path)` is in canonical format.", true)
else
diff = format_diff(
Expand Down
30 changes: 30 additions & 0 deletions test/test_project_toml_formatting.jl
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,36 @@ using Test
@test t false
@test occursin("is not in canonical format", string(t))
end
@testset "pass: weakdeps + extensions following Pkg >= 1.7" begin
@test _analyze_project_toml_formatting_2(
path,
"""
name = "Aqua"
uuid = "4c88cf16-eb10-579e-8560-4a9242c79595"
authors = ["Takafumi Arakaki <aka.tkf@gmail.com>"]
version = "0.4.7-DEV"
[deps]
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
[weakdeps]
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
[extensions]
AquaRandomExt = "Random"
[compat]
julia = "1.0"
[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
[targets]
test = ["Test"]
""",
) true
end
end

end # module

0 comments on commit d2d62f8

Please sign in to comment.