JuliaTesting / Aqua.jl

Auto QUality Assurance for Julia packages
MIT License
334 stars 24 forks source link

`Aqua.test_persistent_tasks()` errors with unregistered dependencies #263

Closed Socob closed 5 months ago

Socob commented 7 months ago

When running the following example, where Aqua.test_persistent_tasks() is used on a package that has an unregistered dependency, I get an error:

using Aqua
using Pkg

cd(mktempdir())
Pkg.generate("TestPkg")
Pkg.activate("TestPkg")
Pkg.add(url="https://github.com/00vareladavid/Unregistered.jl")

using TestPkg

Aqua.test_persistent_tasks(TestPkg)

The output is as follows:

  Generating  project TestPkg:
    TestPkg/Project.toml
    TestPkg/src/TestPkg.jl
  Activating project at `/tmp/jl_yyPR6z/TestPkg`
    Updating git-repo `https://github.com/00vareladavid/Unregistered.jl`
   Resolving package versions...
    Updating `/tmp/jl_yyPR6z/TestPkg/Project.toml`
  [dcb67f36] + Unregistered v0.2.0 `https://github.com/00vareladavid/Unregistered.jl#master`
    Updating `/tmp/jl_yyPR6z/TestPkg/Manifest.toml`
  [7876af07] + Example v0.5.3
  [dcb67f36] + Unregistered v0.2.0 `https://github.com/00vareladavid/Unregistered.jl#master`
Precompiling project...
  1 dependency successfully precompiled in 1 seconds. 2 already precompiled.
Error During Test at ~/.julia/packages/Aqua/9p8ck/src/persistent_tasks.jl:29
  Test threw exception
  Expression: !(has_persistent_tasks(package; kwargs...))
  Unsatisfiable requirements detected for package Unregistered [dcb67f36]:
   Unregistered [dcb67f36] log:
   ├─Unregistered [dcb67f36] has no known versions!
   └─restricted to versions * by TestPkg [0d50a1e8] — no versions left
     └─TestPkg [0d50a1e8] log:
       ├─possible versions are: 0.1.0 or uninstalled
       └─TestPkg [0d50a1e8] is fixed to version 0.1.0
  Stacktrace:
    [1] check_constraints(graph::Pkg.Resolve.Graph)
      @ Pkg.Resolve ~/.julia/juliaup/julia-1.10.0+0.x64.linux.gnu/share/julia/stdlib/v1.10/Pkg/src/Resolve/graphtype.jl:998
    [2] Pkg.Resolve.Graph(compat::Dict{Base.UUID, Dict{VersionNumber, Dict{Base.UUID, Pkg.Versions.VersionSpec}}}, compat_weak::Dict{Base.UUID, Dict{VersionNumber, Set{Base.UUID}}}, uuid_to_name::Dict{Base.UUID, String}, reqs::Dict{Base.UUID, Pkg.Versions.VersionSpec}, fixed::Dict{Base.UUID, Pkg.Resolve.Fixed}, verbose::Bool, julia_version::VersionNumber)
      @ Pkg.Resolve ~/.julia/juliaup/julia-1.10.0+0.x64.linux.gnu/share/julia/stdlib/v1.10/Pkg/src/Resolve/graphtype.jl:345
    [3] deps_graph(env::Pkg.Types.EnvCache, registries::Vector{Pkg.Registry.RegistryInstance}, uuid_to_name::Dict{Base.UUID, String}, reqs::Dict{Base.UUID, Pkg.Versions.VersionSpec}, fixed::Dict{Base.UUID, Pkg.Resolve.Fixed}, julia_version::VersionNumber, installed_only::Bool)
      @ Pkg.Operations ~/.julia/juliaup/julia-1.10.0+0.x64.linux.gnu/share/julia/stdlib/v1.10/Pkg/src/Operations.jl:586
    [4] resolve_versions!(env::Pkg.Types.EnvCache, registries::Vector{Pkg.Registry.RegistryInstance}, pkgs::Vector{Pkg.Types.PackageSpec}, julia_version::VersionNumber, installed_only::Bool)
      @ Pkg.Operations ~/.julia/juliaup/julia-1.10.0+0.x64.linux.gnu/share/julia/stdlib/v1.10/Pkg/src/Operations.jl:406
    [5] targeted_resolve(env::Pkg.Types.EnvCache, registries::Vector{Pkg.Registry.RegistryInstance}, pkgs::Vector{Pkg.Types.PackageSpec}, preserve::Pkg.Types.PreserveLevel, julia_version::VersionNumber)
      @ Pkg.Operations ~/.julia/juliaup/julia-1.10.0+0.x64.linux.gnu/share/julia/stdlib/v1.10/Pkg/src/Operations.jl:1360
    [6] tiered_resolve(env::Pkg.Types.EnvCache, registries::Vector{Pkg.Registry.RegistryInstance}, pkgs::Vector{Pkg.Types.PackageSpec}, julia_version::VersionNumber, try_all_installed::Bool)
      @ Pkg.Operations ~/.julia/juliaup/julia-1.10.0+0.x64.linux.gnu/share/julia/stdlib/v1.10/Pkg/src/Operations.jl:1349
    [7] _resolve(io::Base.DevNull, env::Pkg.Types.EnvCache, registries::Vector{Pkg.Registry.RegistryInstance}, pkgs::Vector{Pkg.Types.PackageSpec}, preserve::Pkg.Types.PreserveLevel, julia_version::VersionNumber)
      @ Pkg.Operations ~/.julia/juliaup/julia-1.10.0+0.x64.linux.gnu/share/julia/stdlib/v1.10/Pkg/src/Operations.jl:1370
    [8] develop(ctx::Pkg.Types.Context, pkgs::Vector{Pkg.Types.PackageSpec}, new_git::Set{Base.UUID}; preserve::Pkg.Types.PreserveLevel, platform::Base.BinaryPlatforms.Platform)
      @ Pkg.Operations ~/.julia/juliaup/julia-1.10.0+0.x64.linux.gnu/share/julia/stdlib/v1.10/Pkg/src/Operations.jl:1410
    [9] develop
      @ ~/.julia/juliaup/julia-1.10.0+0.x64.linux.gnu/share/julia/stdlib/v1.10/Pkg/src/Operations.jl:1402 [inlined]
   [10] develop(ctx::Pkg.Types.Context, pkgs::Vector{Pkg.Types.PackageSpec}; shared::Bool, preserve::Pkg.Types.PreserveLevel, platform::Base.BinaryPlatforms.Platform, kwargs::@Kwargs{io::Base.DevNull})
      @ Pkg.API ~/.julia/juliaup/julia-1.10.0+0.x64.linux.gnu/share/julia/stdlib/v1.10/Pkg/src/API.jl:225
   [11] develop(pkgs::Vector{Pkg.Types.PackageSpec}; io::Base.DevNull, kwargs::@Kwargs{})
      @ Pkg.API ~/.julia/juliaup/julia-1.10.0+0.x64.linux.gnu/share/julia/stdlib/v1.10/Pkg/src/API.jl:159
   [12] develop
      @ ~/.julia/juliaup/julia-1.10.0+0.x64.linux.gnu/share/julia/stdlib/v1.10/Pkg/src/API.jl:148 [inlined]
   [13] develop
      @ ~/.julia/juliaup/julia-1.10.0+0.x64.linux.gnu/share/julia/stdlib/v1.10/Pkg/src/API.jl:146 [inlined]
   [14] precompile_wrapper(project::String, tmax::Int64, expr::Expr)
      @ Aqua ~/.julia/packages/Aqua/9p8ck/src/persistent_tasks.jl:84
   [15] has_persistent_tasks(package::Base.PkgId; expr::Expr, tmax::Int64)
      @ Aqua ~/.julia/packages/Aqua/9p8ck/src/persistent_tasks.jl:40
   [16] has_persistent_tasks(package::Base.PkgId)
      @ Aqua ~/.julia/packages/Aqua/9p8ck/src/persistent_tasks.jl:37
   [17] macro expansion
      @ ~/.julia/packages/Aqua/9p8ck/src/persistent_tasks.jl:29 [inlined]
   [18] macro expansion
      @ ~/.julia/juliaup/julia-1.10.0+0.x64.linux.gnu/share/julia/stdlib/v1.10/Test/src/Test.jl:669 [inlined]
   [19] test_persistent_tasks(package::Base.PkgId; broken::Bool, kwargs::@Kwargs{})
      @ Aqua ~/.julia/packages/Aqua/9p8ck/src/persistent_tasks.jl:29
ERROR: LoadError: There was an error during testing
in expression starting at ~/tmp/test.jl:11

Not sure if I’m doing anything wrong here, but it doesn’t seem like Aqua.test_persistent_tasks() should be affected by whether a package is registered or not.

lgoettgens commented 5 months ago

The test_persistent_tasks function creates a new package with your package as a dependency and tries to precompile it. If your package has unregistered dependencies, you cannot use it as a dependency of any package. I'll add a note to the docstring explaining this.