Several times recently while developing Julia packages, I have found myself needing to test that a particular package feature does not result in precompilation warnings or errors when used by other packages. Often this is because calling the feature does some code generation including method definition, which can lead to overwritten methods that Julia’s precompilation process will complain about, but which calling the feature in a script leads to no issues (e.g. this issue in Gen.jl which I finally managed to fix).
However, it’s not clear to me how test for such warnings using Julia’s current testing infrastructure for packages. It’s not enough to just create nested modules in test scripts, because those modules don’t get precompiled. Rather, I’ve found that I have to manually create dummy packages (sometimes mulitple) that import the package I’m developing, and then trigger precompilation of those packages in order to make sure there are no precompilation issues.
For e.g., for the fix I mentioned above, I had to create three packages with the following dependency structure in order to test the package PkgToTest
:
[[TestPkg]]
deps = ["TestSubPkgA", "TestSubPkgB"]
[[TestSubPkgA]]
deps = ["PkgToTest"]
[[TestSubPkgB]]
deps = ["PkgToTest"]
Is there a simpler way to do this that I’m missing, and that can be run by calling Pkg.test
so that I can be assured by CI against any precompilation errors? Or does this functionality / tooling not exist right now?