lib/xcov/manager.rb in xcov-1.5.0 vs lib/xcov/manager.rb in xcov-1.5.1
- old
+ new
@@ -35,16 +35,21 @@
FileUtils.rm_rf(tmp_dir) if File.directory?(tmp_dir)
end
def parse_xccoverage
# Find .xccoverage file
- extension = Xcov.config[:legacy_support] ? "xccoverage" : "xccovreport"
- test_logs_path = derived_data_path + "Logs/Test/"
- xccoverage_files = Dir["#{test_logs_path}*.#{extension}", "#{test_logs_path}*.xcresult/*/action.#{extension}"].sort_by { |filename| File.mtime(filename) }.reverse
+ # If no xccov direct path, use the old derived data path method
+ if xccov_file_direct_path.nil?
+ extension = Xcov.config[:legacy_support] ? "xccoverage" : "xccovreport"
+ test_logs_path = derived_data_path + "Logs/Test/"
+ xccoverage_files = Dir["#{test_logs_path}*.#{extension}", "#{test_logs_path}*.xcresult/*/action.#{extension}"].sort_by { |filename| File.mtime(filename) }.reverse
- unless test_logs_path.directory? && !xccoverage_files.empty?
- ErrorHandler.handle_error("XccoverageFileNotFound")
+ unless test_logs_path.directory? && !xccoverage_files.empty?
+ ErrorHandler.handle_error("XccoverageFileNotFound")
+ end
+ else
+ xccoverage_files = ["#{xccov_file_direct_path}"]
end
# Convert .xccoverage file to json
ide_foundation_path = Xcov.config[:legacy_support] ? nil : Xcov.config[:ideFoundationPath]
json_report = Xcov::Core::Parser.parse(xccoverage_files.first, Xcov.config[:output_directory], ide_foundation_path)
@@ -124,11 +129,11 @@
def validate_report(report)
# Raise exception if overall coverage is under threshold
minimumPercentage = Xcov.config[:minimum_coverage_percentage] / 100
if minimumPercentage > report.coverage
- error_message = "Actual Code Coverage (#{"%.2f%" % (report.coverage*100)}) below threshold of #{"%.2f%" % (minimumPercentage*100)}"
+ error_message = "Actual Code Coverage (#{"%.2f%%" % (report.coverage*100)}) below threshold of #{"%.2f%%" % (minimumPercentage*100)}"
ErrorHandler.handle_error_with_custom_message("CoverageUnderThreshold", error_message)
end
end
def submit_to_coveralls(report)
@@ -139,17 +144,24 @@
CoverallsHandler.submit(report)
end
end
# Auxiliar methods
-
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
+
+ def xccov_file_direct_path
+ # If xccov_file_direct_path was supplied, return
+ if Xcov.config[:xccov_file_direct_path].nil?
+ return nil
+ end
+ return Pathname.new(Xcov.config[:xccov_file_direct_path])
end
end
end