-
Notifications
You must be signed in to change notification settings - Fork 93
Description
I recently had a strange run-in with @quickactivate
in a new DrWatson project I am working on, where it does not activate the project with the given name, but rather the first project that it comes across, starting from the directory of the executed file. My project structure looks somewhat like this:
MyProject
| src
| | MyProject.jl
| Project.toml # defining the MyProject package
| test
| | Project.toml # defining the Test dependencies
| | current.jl
| | runtests.jl
...
I am using the current.jl
file, located in the test folder, as some kind of scratchspace to prototype every functionality that I eventually integrate into the package, tests, scripts and so on. This file starts with
using DrWatson
@quickactivate :MyProject
# some throwaway code
Executing the first two lines in this file, I would expect it to search for, find and activate the project with the given file (in this case at MyProject/Project.toml
). However, because current.jl
is located in the test folder, it finds the MyProject/test/Project.toml
file, activates it, and then throws an error:
Activating project at `~/MyProject/test`
ERROR: The activated project did not match asserted name. Current project name is nothing while the asserted name is MyProject.
(reexecuting the @quickactivate :MyProject
then just silently fails, not rethrowing the error.)
Intuitively, I would expect it to keep searching upwards until it finds a project with the given name to activate, and to fail if there is none, without changing the currently activated project (I know that this is documented, however it is still unintuitive behaviour to me).
I realise that changing this behaviour is probably breaking in many ways, but maybe there could be a keyword added to @quickactivate
such as
# only activates the project if the name matches
@quickactivate : MyProject matchonly=true
@quickactivate :MyProject matchonly=false
# same as
@quickactivate :MyProject
or another macro
@quickactivate_matched :MyProject