Closed callendorph closed 1 year ago
Hi! I think I can provide some context to this one in case anyone else runs into it -
The build-test
command will add a TESTING
define to the compiler invocation, which invalidates the cached .pkg files.
Consider this code :
defpackage my-package :
import core
import collections
public-when(TESTING) defn my-private-function () :
"hello!"
defpackage my-package/tests :
import core
import collections
deftest test-my-private-function :
#ASSERT(my-private-function() == "hello!")
The cached .pkg file of my-package
will need to know: what are my functions, and what are their visibility? In this case, the TESTING
flag will invalidate the .pkg, since it changes the visibility of a function in the package, and needs to be recompiled. At the moment the compiler can't guarantee that the cached .pkg files compiled with one set of flags is the same as another, so it makes a conservative choice to recompile everything. It would be great to see more incrementalism in the future, though!
One way to work around this is to have two pkg directories in your build folder, one for artifacts compiled normally, and one for those compiled during testing.
OK - thank you!
Thanks for the explanation Mike. That is exactly what's happening.
In this project:
https://github.com/callendorph/lbstanza-tidy
I have two build targets - main and tidy-tests https://github.com/callendorph/lbstanza-tidy/blob/36cebf5516b0668bbdf6b3ef5c8f57418d81df43/stanza.proj#L11
They both should generate the
*.pkg
artifacts in thepkgs
directory.What I find is that even if I run
stanza build main
before runningstanza build tidy-tests
- Thetidy-tests
target will rebuild all of the*.pkg
files from scratch. Example:Here is the commands I run in the command line:
Here is a log of filesystem events generated when this sequence ran:
https://gist.github.com/callendorph/39c27a2655939ae7774fc1fecf9a4a50
Here is a zip file of the strace output for
stanza build tidy-tests
strace -f stanza build tidy-tests &> strace.list
stanza_build_tidy-tests_strace.zip
In this trace you will see the following:
*.pkg
files for the Enums asO_RDONLY
. This is what I expect it to do*.pkg
files asO_WRONLY|O_CREAT|O_TRUNC
which I believe will clobber the existing file.Line: 15150
My expectation would be that for these packages, when they get built by
stanza build
that they would be reused instanza build tidy-tests
. Is this not the right expectation ? Is that not what is happening here ?