Fork me on GitHub
#kaocha
<
2023-01-27
>
rgm19:01:41

I have a little project structuring question around making bin/kaocha --watch work well. I'm making a library that can use either redis or postgres as its store. I'm trying to structure my project as HugSQL has: where to use the lib you'll have to add a dep for the library, and a dep for your choice of store. I'd like to keep them all libs in the same git repo. My basic goal is that if you're using Redis, I don't make you drag in Postgres dependencies like next.jdbc, and vice-versa. The top-level library leans on a protocol. (Again, very similar to hugsql). The require graph is looking like this, and it's working with bin/kaocha but only changes to lib.core are working with bin/kaocha --watch:

┌───────────────┐                ┌───────────────┐
│     app A     │                │     app B     │
└───────────────┘                └───────────────┘
        │          changes to lib.core   │        
        │            get watched OK      │        
        │       ┌───────────────┐        │        
        ├──────▶│   lib.core    │◀───────┤        
        │       └───────────────┘        │        
        │               │                │        
        │               │                │        
        │               │   bin/kaocha   │        
        │               │ --watch can't  │        
        │               │ see changes to │        
        │               │  lib.redis or  │        
        ▼               │  lib.postgres  ▼        
┌───────────────┐       │        ┌───────────────┐
│ lib.postgres  │       │        │   lib.redis   │
└───────────────┘       │        └───────────────┘
        │               │                │        
        └───────────────┼────────────────┘        
                        │                         
                        ▼                         
                ┌───────────────┐                 
                │  lib.adapter  │                 
                └───────────────┘                            
My first try is at https://github.com/rgm/hyak2/tree/postgres-initial/modules. The annoyance I'm trying to squish is that the kaocha watcher picks up changes to $gitroot/src and $gitroot/test fine, but it doesn't seem to be picking up changes in $gitroot/modules/$whatever/src at all. I can work around it a bit just manually re-requiring the namespace from my editor and then invoking a kaocha run all via an nrepl connection. I'm telling my test JVM about the sub-projects via :extra-paths, so I'm thinking maybe that's not quite the right approach (see https://github.com/rgm/hyak2/blob/postgres-initial/deps.edn#L8-L10)

Alys Brooks19:01:12

Have you tried adding the modules to :source-paths in tests.edn? Maybe we should pick up :extra-paths; I'm actually not sure why we have our own :source-paths

rgm18:02:50

:man-facepalming: ... yep, that was it. I'd entirely forgotten about setting :source-paths separately in tests.edn, and was just running with #kaocha/v1 {} in that file. Thanks!