I have gone through a multitude of tutorials now but still can’t seem to wrap my head around the basics of how to write and test a package as I go. I don’t understand the proper way to add my package and its dependencies to the REPL namespace or the proper way to juggle between the Main and MyPackage modules. I keep getting errors that variables, functions, or packages are undefined. I just want the simplest, foolproof workflow.
MyPackagefolder in VSCode made with PkgTemplates.jl.
- Start REPL
MyPackageenvironment (usually done automatically).
I should always stay in
MyPackageenvironment when developing
- I don’t need to
usingRevise because it is built in to the VSCode extension right?
- Should I
using .MyDependency, or some combination?
I would assume that loading
MyPackagewould also load its dependencies, but that doesn’t always seem to be true. I have also seen some tutorials not
using MyPackageat all and just send code to the REPL.
- How do I ensure my REPL is testing with the package versions in my Project.toml and using the
MyPackageversion from my
module MyPackage; using MyDependency; include("myfile.jl"); end
Should I use
- Start writing code in
- How should I debug?
If I “Run and Debug”
MyPackage.jl, then breakpoints in
myfile.jlare skipped and I just see “Done!”. If I “Run and Debug”
MyDependencyare not loaded and I error out.
- How should I run file code and tinker in REPL?
I like to switch between writing code in file (executing with Ctrl+Enter) and writing code directly in the REPL, but that sometimes switches the current module between
MyPackageso things break. Do I have to stick with one or the other? Which module should my REPL be using?
- How should I test sub-functions?
I can test a function in the REPL with
using MyPackage; f(x). However, if that function contains a sub-function
f_sub(y), the REPL doesn’t have access to its name so I can make sure it works.
- How should I write file paths so they always point to my test data stored in
I have to change the file path if I run code from the test folder or if I move the package.