For some packages it is useful to have a
TestModule that defines functions to generate data, for example. It is many times interesting that these functions are available for the package user, particularly to provide examples of the package usage.
TestModule gets complex, and particularly when it depends on other packages that are not main deps of the package, carrying the module within the package becomes bad for loading times.
With the new
[extensions] that may be solved, and I would like to hear thoughts about this possibility:
1. Create the package
MyPackage, containing a
TestModule, which may depend on a heavy dependency:
module MyPackage ... include("./test/TestModule.jl") end # ./test/TestModule.jl module TestModule using Plots # heavy! ... end
2. Create a dummy
MyPackageTests package, basically empty, and register it.
3. Have the
MyPackage to be:
name = "MyPackage" version = "0.1.0" uuid = "..." [weakdeps] MyPackageTests = "d38c429a-6771-53c6-b99e-75d170b6e991" [extensions] Plots = "MyPackageTests" # only loaded if MyPackageTests is loaded [compat] MyPackageTests = "0.1.0" Plots = "0.6.2"
One can develop
MyPackage only all the time, and use/update the functions of
TestModule easily. Also, all the functions there can be provided as example/test functions for users, such as:
using MyPackage: foo using MyPackageTests # loads all dependencies of TestModule data = MyPackage.TestModule.generate_data() MyPackage.foo(data)
Is there any obvious downside of this? Having to register a dummy package seems overkill here, but not a major problem.
TestModule package will never be loaded from within the functions of
MyPackage, such that the implications for loading time of
MyPackage are minimal (if any?). Or is this wrong?