Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Dev Workflow Docs #301

Merged
merged 4 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ makedocs(
"Debug Mode" => "debug_mode.md",
"Debugging and MWEs" => "debugging_and_mwes.md",
],
"Developer Documentation" => [
"Running Tests Locally" => "running_tests_locally.md",
],
"Known Limitations" => "known_limitations.md",
]
)
Expand Down
23 changes: 23 additions & 0 deletions docs/src/running_tests_locally.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Running Tests Locally

Mooncake.jl's test suite is fairly extensive. While you can use `Pkg.test` to run the test suite in the standard manner, this is not usually optimal in Mooncake.jl. When editing some code, you typically only want to run the tests associated with it, not the entire test suite.

Mooncake's tests are organised as follows:
1. Things that are required for most / all test suites are loaded up in `test/front_matter.jl`.
1. The tests for something in `src` are located in an identically-named file in `test`. e.g. the unit tests for `src/rrules/new.jl` are located in `test/rrules/new.jl`.

Thus, a workflow that I (Will) find works very well is the following:
1. Ensure that you have Revise.jl and TestEnv.jl installed in your default environment.
1. start the REPL, `dev` Mooncake.jl, and navigate to the top level of the Mooncake.jl directory.
1. `using TestEnv, Revise`. Better still, load both of these in your `.julia/config/startup.jl` file so that you don't ever forget to load them.
1. Run the following: `using Pkg; Pkg.activate("."); TestEnv.activate(); include("test/front_matter.jl");` to set up your environment.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not a suggestion, just a anecdotal point from me: I configure VSCode to automatically do the Pkg.activate() for the package folder I open. But what you wrote is better as it assumes less.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for letting me know -- this is good to know.

1. `include` whichever test file you want to run the tests from.
1. Modify code, and re-`include` tests to check it has done was you need. Loop this until done.
1. Make a PR. This runs the entire test suite -- I find that I almost _never_ run the entire test suite locally.

The purpose of this approach is to:
1. Avoid restarting the REPL each time you make a change, and
2. Run the smallest bit of the test suite possible when making changes, in order to make development a fast and enjoyable process.

If you find that this strategy leaves you running more of the test suite than you would like, consider copy + pasting specific tests into the REPL, or commenting out a chunk of tests in the file that you are editing during development (try not to commit this).
I find this is rather crude strategy effective in practice.
Loading