Class: Xcov::Runner
- Inherits:
-
Object
- Object
- Xcov::Runner
- Defined in:
- lib/xcov/runner.rb
Instance Method Summary collapse
-
#derived_data_path ⇒ Object
Auxiliar methods.
- #generate_xcov_report(report_json) ⇒ Object
- #parse_xccoverage ⇒ Object
- #run ⇒ Object
- #validate_report(report) ⇒ Object
Instance Method Details
#derived_data_path ⇒ Object
Auxiliar methods
96 97 98 99 100 101 102 103 |
# File 'lib/xcov/runner.rb', line 96 def derived_data_path # If DerivedData path was supplied, return return Pathname.new(Xcov.config[:derived_data_path]) unless Xcov.config[:derived_data_path].nil? # Otherwise check project file product_builds_path = Pathname.new(Xcov.project.default_build_settings(key: "SYMROOT")) return product_builds_path.parent.parent end |
#generate_xcov_report(report_json) ⇒ Object
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 71 72 73 74 75 76 77 78 |
# File 'lib/xcov/runner.rb', line 30 def generate_xcov_report report_json # Create output path output_path = Xcov.config[:output_directory] FileUtils.mkdir_p(output_path) resources_path = File.join(output_path, "resources") FileUtils.mkdir_p(resources_path) # Copy images to output resources folder Dir[File.join(File.dirname(__FILE__), "../../assets/images/*")].each do |path| FileUtils.cp_r(path, resources_path) end # Copy stylesheets to output resources folder Dir[File.join(File.dirname(__FILE__), "../../assets/stylesheets/*")].each do |path| FileUtils.cp_r(path, resources_path) end # Copy javascripts to output resources folder Dir[File.join(File.dirname(__FILE__), "../../assets/javascripts/*")].each do |path| FileUtils.cp_r(path, resources_path) end # Convert report to xCov model objects report = Report.map(report_json) # Create HTML report File.open(File.join(output_path, "index.html"), "wb") do |file| file.puts report.html_value end # Post result SlackPoster.new.run(report) # Print output table_rows = [] report.targets.each do |target| table_rows << [target.name, target.displayable_coverage] end puts Terminal::Table.new({ title: "xcov Coverage Report".green, rows: table_rows }) puts "" # Raise exception in case of failure raise "Unable to create coverage report" if report.nil? report end |
#parse_xccoverage ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/xcov/runner.rb', line 18 def parse_xccoverage # Find .xccoverage file test_logs_path = derived_data_path + "Logs/Test/" xccoverage_files = Dir["#{test_logs_path}*.xccoverage"].sort_by { |filename| File.mtime(filename) }.reverse unless test_logs_path.directory? && !xccoverage_files.empty? ErrorHandler.handle_error("CoverageNotFound") end Xcov::Core::Parser.parse(xccoverage_files.first) end |
#run ⇒ Object
12 13 14 15 16 |
# File 'lib/xcov/runner.rb', line 12 def run report_json = parse_xccoverage report = generate_xcov_report(report_json) validate_report(report) end |
#validate_report(report) ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/xcov/runner.rb', line 80 def validate_report report exit_status = 0 # Raise exception if overall coverage minimumPercentage = Xcov.config[:minimum_coverage_percentage] / 100 if minimumPercentage > report.coverage exit_status = 1 UI.user_error!("Actual Code Coverage (#{"%.2f%" % (report.coverage*100)}) below threshold of #{"%.2f%" % (minimumPercentage*100)}") end exit_status end |