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

compat entry for Test #466

Open
putianyi889 opened this issue Mar 26, 2024 · 3 comments
Open

compat entry for Test #466

putianyi889 opened this issue Mar 26, 2024 · 3 comments

Comments

@putianyi889
Copy link

The auto-generated Project.toml doesn't pass Aqua test:

PkgName [uuid] does not declare a compat entry for the following extras:
1-element Vector{Base.PkgId}:
 Test [8dfed614-e22c-5e08-85e1-65c5234f0b40]
@gdalle
Copy link
Collaborator

gdalle commented Mar 26, 2024

Good catch! Do you want to try and fix it in a PR? I can help

@putianyi889
Copy link
Author

Good catch! Do you want to try and fix it in a PR? I can help

I'd like to, but I'm not sure if I'll need to change the definition of Template as it stores the Julia version.

@gdalle
Copy link
Collaborator

gdalle commented Mar 27, 2024

No, I think it just requires editing the Test plugin. Two cases to consider: separate Project.toml file or [extras] section in the main one. I think in both cases, you should be able to set the version for Test with Pkg.compat: https://pkgdocs.julialang.org/v1/api/#Pkg.compat

The relevant lines to edit are here:

function hook(p::Tests, t::Template, pkg_dir::AbstractString)
# Do the normal FilePlugin behaviour to create the test script.
invoke(hook, Tuple{FilePlugin,Template,AbstractString}, p, t, pkg_dir)
# Then set up the test depdendency in the chosen way.
if p.project
make_test_project(p, pkg_dir)
else
add_test_dependency(p, pkg_dir)
end
end
# Create a new test project.
function make_test_project(p::Tests, pkg_dir::AbstractString)
with_project(() -> Pkg.add(TEST_DEP), joinpath(pkg_dir, "test"))
if p.aqua
with_project(() -> Pkg.add(AQUA_DEP), joinpath(pkg_dir, "test"))
end
if p.jet
with_project(() -> Pkg.add(JET_DEP), joinpath(pkg_dir, "test"))
end
end
# Add Test as a test-only dependency.
function add_test_dependency(p::Tests, pkg_dir::AbstractString)
# Add the dependency manually since there's no programmatic way to add to [extras].
path = joinpath(pkg_dir, "Project.toml")
toml = TOML.parsefile(path)
get!(toml, "extras", Dict())["Test"] = TEST_UUID
if p.aqua
get!(toml, "extras", Dict())["Aqua"] = AQUA_UUID
end
if p.jet
get!(toml, "extras", Dict())["JET"] = JET_UUID
end
targets = String[]
if p.aqua
push!(targets, "Aqua")
end
if p.jet
push!(targets, "JET")
end
push!(targets, "Test")
get!(toml, "targets", Dict())["test"] = targets
write_project(path, toml)
# Generate the manifest by updating the project.
with_project(Pkg.update, pkg_dir)
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants