Open jonathanpallant opened 1 year ago
I implemented this behavior in the simplest possible way here https://github.com/stevecheckoway/mdBook/commit/8774e76d7b14c4ce3e9ca7591af9cbc03cdcfaa1. I added a (user-configurable) cache directory. The test_chapter()
function checks if, for a given chapter path, there is a corresponding file in the cache directory that is newer than the source file. If so, the test is skipped.
If this is something that the maintainers would like, I'd be happy to work on making a PR out of this with documentation and tests (with some suggestions for how to test).
The difference in speed is exactly what you'd expect: Testing 75 chapters (not all of which actually contain rust code) of a book of mine takes 10 seconds on my laptop according to zsh:
7.13s user 3.34s system 101% cpu 10.282 total
After making a change to just one chapter, testing takes less than a second.
0.18s user 0.10s system 67% cpu 0.417 total
Problem
I have a book with lots of code examples. Running
mdbook test
takes 7 seconds, even though I'm not changing most of my chapters and only working on one file.Proposed Solution
I would like
mdbook test
to cache somewhere information about the files it has tested so it can skip the tests if the file is unchanged.It could write to something like a: unchanged so tests skipped".
.mdbook-test
file in the same directory as thebook.toml
file noting the filename, sha256sum and timestamp of each file it has tested. If the file is newer, or different, the test should be run. If the file is of the recorded age and has the recorded checksum, it should print "Testing chapterNotes
No response