Class: Autoproj::CLI::TestPostprocessing
- Inherits:
-
InspectionTool
- Object
- InspectionTool
- Autoproj::CLI::TestPostprocessing
- Defined in:
- lib/autoproj/cli/test_postprocessing.rb
Defined Under Namespace
Classes: ConvertionFailed
Constant Summary collapse
- TEST_RESULT_CONVERTERS =
Hash[ '*.boost.xml' => File.join(test_format_converter_dir, 'boost-test.xsl'), '*.junit.xml' => nil ]
Instance Attribute Summary collapse
-
#convertions ⇒ Object
readonly
Returns the value of attribute convertions.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(ws, convertions: TEST_RESULT_CONVERTERS) ⇒ TestPostprocessing
constructor
A new instance of TestPostprocessing.
- #process(output_dir, *package_names, after: nil) ⇒ Object
- #xsl_process(input_file, stylesheet, output_file) ⇒ Object
Constructor Details
#initialize(ws, convertions: TEST_RESULT_CONVERTERS) ⇒ TestPostprocessing
Returns a new instance of TestPostprocessing.
19 20 21 22 |
# File 'lib/autoproj/cli/test_postprocessing.rb', line 19 def initialize(ws, convertions: TEST_RESULT_CONVERTERS) super(ws) @convertions = convertions end |
Instance Attribute Details
#convertions ⇒ Object (readonly)
Returns the value of attribute convertions.
6 7 8 |
# File 'lib/autoproj/cli/test_postprocessing.rb', line 6 def convertions @convertions end |
Class Method Details
.test_format_converter_dir ⇒ Object
8 9 10 11 12 |
# File 'lib/autoproj/cli/test_postprocessing.rb', line 8 def self.test_format_converter_dir File.( File.join('..', 'jenkins', 'test_format_converters'), __dir__) end |
Instance Method Details
#process(output_dir, *package_names, after: nil) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/autoproj/cli/test_postprocessing.rb', line 26 def process(output_dir, *package_names, after: nil) initialize_and_load source_packages, _ = finalize_setup(package_names, recursive: false) source_packages = source_packages.map do |package_name| ws.manifest.package_definition_by_name(package_name) end has_failures = false source_packages.each do |pkg| utility = pkg.autobuild.test_utility found_something = false convertions.each do |glob, xsl| Dir.glob(File.join(utility.target_dir, glob)) do |input_file| input_mtime = File.stat(input_file).mtime if after && input_mtime < after Autoproj. " ignoring #{input_file}, its modification time is #{input_mtime} which is after #{after}" next end found_something = true FileUtils.mkdir_p output_dir output_file = File.join(output_dir, File.basename(input_file)) begin if xsl xsl_process(input_file, xsl, output_file) else FileUtils.copy_file input_file, output_file end Autoproj. " generated #{output_file} from #{input_file} for #{pkg.name}" rescue Exception => e Autoproj.error e. has_failures = true end end end if !found_something Autoproj. "found no test results for #{pkg.name}" end end ensure if has_failures raise ConvertionFailed, "some files failed to convert, see output for more details" end end |
#xsl_process(input_file, stylesheet, output_file) ⇒ Object
72 73 74 75 76 77 78 79 80 |
# File 'lib/autoproj/cli/test_postprocessing.rb', line 72 def xsl_process(input_file, stylesheet, output_file) if File.read(input_file).strip.empty? return end if !system('saxonb-xslt', "-o:#{output_file}", "-xsl:#{stylesheet}", "-s:#{input_file}") raise ArgumentError, "failed to convert #{input_file} using #{stylesheet}" end end |