Bonjour again, do you have a way to combine script...
# scripting
j
Bonjour again, do you have a way to combine scripting and unit testing? Like if I have pure functions or a Regex inside my script, I would like to be able to unit test it so that the script itself is only a small imperative shell around the functional core
b
Only functional testing I guess where you invoke your script from shell and assert console and fs outputs
i.e. no dedicated script test framework unless you set one up yourself
j
So probably a separate repo where I can unit test stuff and then I copy/paste in the script when it's ready
b
Not necessarily. Just have a test-only gradle jvm project in the repo and inject script file path via gradle task env vars
Or do you mean copying from .kt onto .kts file?
That can also be quite easily automated with custom gradle task (just merge all kt files into kts and extract @Import statements from gradle dependencies
j
That could be cool
Ever wondered how to unit test your Kotlin Scripts? Following a suggestion from @Big Chungus I have put together a repository where scripts in a
bin
repository coexist with a normal Gradle project There's a way to mark a block of text as something you want to use in your Kotlin scripts, and a Gradle task that extract them from your KT files and update your KTS files with it https://github.com/jmfayard/my-kotlin-scipts