Pkg.activate vs Base.set_active_project

Can someone please explain the difference between Pkg.activate vs Base.set_active_project from a practical perspective? I looked at the source and they do slightly different things (besides setting Base.ACTIVE_PROJECT[]).

I want to do the following:

  1. given a local path, which should default to the active project,
  2. activate that project,
  3. (ideally, check that it is a package, not test/ or a similar subproject, but I can skip that),
  4. run tests, collect coverage,
  5. activate the previous project.

All of this with a try ... finally to do step 6. if anything fails.

It is unclear which entry functions one should use for this, because they have different effects (eg dealing with Base.active_project_callbacks). Surprisingly, the Pkg.activate(::Function, ::AbstractString) is the most barebones.

[FWIW, I am revamping the API of LocalCoverage.jl ]