WARNINGs on stdout
I am trying to replace kscript with ktx here https://github.com/py2many/py2many/blob/main/tests/test_cli.py#L59
To do that, ktx needs to be able to run files like https://github.com/py2many/py2many/blob/main/tests/expected/coverage.kt , and https://github.com/py2many/py2many/blob/main/tests/expected/sys_argv.kt , and capture their stdout .
What happens is ktx emits on stdout Kotlin compilation warnings:
WARNING: Condition '1 != null' is always 'true'
WARNING: Variable '_escape_quotes' is never used
WARNING: The expression is unused
WARNING: Variable '_c1' is never used
WARNING: Variable '_c2' is never used
WARNING: Parameter 'argv' is never used
They should be on stderr, or just hidden unless explicitly requested.
And I do not get any of the expected output.
These warnings only get printed on initial run as subsequent runs use precompiled and cached versions of the script. All other output us piped to jvm stdout and stderr
Can we move them to stderr? I am comparing stdout to the output of the same script in a different language.
Probably not implicitly, but I could expose some configuration options to control outputs a bit better on consumer end. For now you could intercept stdin and filter out all lines starting with WARNING as a workaround
Ya, I could filter out the WARNINGS.
Any idea why I am not getting the expected output of the println in https://github.com/py2many/py2many/blob/main/tests/expected/coverage.kt ?
None off the top of my head, but I'll investigate it tomorrow.
Wait, hold on. Are you sure that file actually does anything at all once you try to run it with ktx? It's not a .kts script, but rather regular kotlin file which ktx does not explicitly support so I'd be surprised if it even compiles 😮
It runs under https://github.com/kscripting/kscript/