bashcov
bashcov copied to clipboard
Coverage report is not generated when running the bash script via Java getRuntime().exec()
Hi,
I am executing a bash script from Java code using Java getRuntime().exec() as below. Though the script executed without any issues, still the coverage report is not generated String[] cmd = new String[]{"echo", ""SUDOPASSWORD"", "|", "sudo", "-s", "bashcov", "/tmp/script.sh", "--root", "/tmp/"}; Runtime.getRuntime().exec(cmd);
Is there a known limitation in running this way?
@randheerar -- what version of Bashcov are you using? Given that you are running Bashcov as root, this may be related to #31, #43, #56 (Bash versions 4.4 and above, when run as root, do not inherit PS4 from their environment). If you are not on Bashcov 3.x, could you please upgrade Bashcov and then check whether the issue persists?
For what it's worth, I don't think that there are any known limitations with running Bashcov under Java.
@tomeon bashcov 3.1.2 with Bash 5.1, Ruby 3.0.4, and SimpleCov 0.22.0 Let me check if there is any new update
3.1.2 is the latest release, and the bashcov executable in this release can be run as root (though "it is not recommended", to quote the linked changelog entry).
@randheerar -- could you provide a link to the code that suffers from this issue, if one is available? Otherwise, could you provide a minimal reproduction case that I can test?
@tomeon Apologies for the delay. With v3.1.2, I was able to get the coverage. Let me start with that.
Thanks a lot for the help!
Looks like this is resolved, thank you @tomeon :)