Skip to content

Commit 801677d

Browse files
gdallelgoettgens
authored andcommitted
Skip Project formatting if VERSION < 1.7 and there are weakdeps
1 parent a9fedbe commit 801677d

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

src/project_toml_formatting.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,13 @@ function _analyze_project_toml_formatting_2(path::AbstractString, original)
4848

4949
prj = TOML.parse(original)
5050
formatted = sprint(print_project, prj)
51-
if splitlines(original) == splitlines(formatted)
51+
if VERSION < v"1.7" && (haskey(prj, "weakdeps") || haskey(prj, "extensions"))
52+
LazyTestResult(
53+
label,
54+
"The file `$(path)` has not been tested because it has weak dependencies and Julia is in version $VERSION < 1.7.",
55+
true,
56+
)
57+
elseif splitlines(original) == splitlines(formatted)
5258
LazyTestResult(label, "The file `$(path)` is in canonical format.", true)
5359
else
5460
diff = format_diff(

test/test_project_toml_formatting.jl

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,36 @@ using Test
7676
@test t false
7777
@test occursin("is not in canonical format", string(t))
7878
end
79+
@testset "pass: weakdeps + extensions following Pkg >= 1.7" begin
80+
@test _analyze_project_toml_formatting_2(
81+
path,
82+
"""
83+
name = "Aqua"
84+
uuid = "4c88cf16-eb10-579e-8560-4a9242c79595"
85+
authors = ["Takafumi Arakaki <[email protected]>"]
86+
version = "0.4.7-DEV"
87+
88+
[deps]
89+
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
90+
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
91+
92+
[weakdeps]
93+
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
94+
95+
[extensions]
96+
AquaRandomExt = "Random"
97+
98+
[compat]
99+
julia = "1.0"
100+
101+
[extras]
102+
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
103+
104+
[targets]
105+
test = ["Test"]
106+
""",
107+
) true
108+
end
79109
end
80110

81111
end # module

0 commit comments

Comments
 (0)