ktx icon indicating copy to clipboard operation
ktx copied to clipboard

WARNINGs on stdout

Open jayvdb opened this issue 3 years ago • 7 comments

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.

jayvdb avatar Feb 11 '23 10:02 jayvdb

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

mpetuska avatar Feb 11 '23 13:02 mpetuska

Can we move them to stderr? I am comparing stdout to the output of the same script in a different language.

jayvdb avatar Feb 11 '23 13:02 jayvdb

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

mpetuska avatar Feb 11 '23 14:02 mpetuska

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 ?

jayvdb avatar Feb 11 '23 16:02 jayvdb

None off the top of my head, but I'll investigate it tomorrow.

mpetuska avatar Feb 11 '23 17:02 mpetuska

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 😮

mpetuska avatar Feb 11 '23 17:02 mpetuska

It runs under https://github.com/kscripting/kscript/

jayvdb avatar Feb 11 '23 17:02 jayvdb