Fork me on GitHub
Noah Bogart18:10:30

i’m considering using rewrite-clj to rewrite/rearrange my test suite. it’s currently written in the philosophy of “few deftests, many testing branches”, which makes running specific branches hard. i’m looking to pluck each testing branch out of the deftests and then place them in a new deftest with some name. would this be possible with rewrite-clj?


@nbtheduke That is something that I've thought about too: it's better to have more deftests rather than single big tests: it's much easier to invoke them separately.


And yes, rewrite-clj is a good tool to do this I think

Noah Bogart20:10:40

yeah, it’s also an issue when our tests are really long, so some of these files are 4k or 5k lines long lol


wondering if the rewrite-clj.paredit would be a good fit, I've never used it but the task sounds 'paredit-y' to me two phases: first move all testings to the top-level, then wrap each one with deftest might be more complex than that though depending on the usage patterns If it's a truly one-off thing I might do the last finishing touches with IDE paredit, sounds cheaper than coding sth fine-grained. @nbtheduke

Noah Bogart20:10:27

if this was purely string manipulation, i’d probably do it with a thread last that filters to deftest blocks, then group by the deftest name, then plucks each testing block, then mapcats with some sort of “wrap each block in a deftest”, then prints them out

Noah Bogart20:10:55

seems like there’s not any sort of sequencing/mapping over zlocs


@nbtheduke Sometimes I find it easier to ignore the whole zipper stuff and just work directly with the nodes and :children

Noah Bogart20:10:21

oh yeah? cool, which part is that?

Noah Bogart20:10:52

oh, found the node api

Noah Bogart21:10:06

yeah, this is much more my speed. cannot believe all of these cool apis exist

Noah Bogart21:10:11

so lucky to work in clojure


I typically first reach for the rewrite-clj zip API myself, but probably only just because that’s what I am used to.


You can combine both approach too. It's just awesome ;)

metal 1