Created
July 11, 2019 14:56
-
-
Save lavoiesl/b58ed9e00943ffafa3faeb09b7fbd608 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'open3' | |
module CheckstyleToJUnit | |
# https://github.com/koalaman/shellcheck/wiki/JUnit | |
XSLT = File.expand_path('../support/checkstyle2junit.xslt', __dir__) | |
class << self | |
def call | |
puts translate(ARGF.read) | |
end | |
def translate(input) | |
out, stat = Open3.capture2('xmlstarlet', 'tr', XSLT, stdin_data: input) | |
abort('xmlstarlet failed') unless stat.success? | |
out | |
end | |
def spawnwait(*args, **kwargs) | |
_, stat = Process.waitpid2(Process.spawn(*args, **kwargs)) | |
stat | |
end | |
def must_spawnwait(*args, **kwargs) | |
stat = spawnwait(*args, **kwargs) | |
abort("#{args.first} failed") unless stat.success? | |
stat | |
end | |
end | |
end | |
__FILE__ == $PROGRAM_NAME and CheckstyleToJUnit.call |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment