pronto-rustcov 0.1.5 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/pronto/rustcov.rb +70 -28
- metadata +45 -3
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 7df000545899a6dcf0010858dce8b6b70fbd490b3267ce907167289be36c746f
         | 
| 4 | 
            +
              data.tar.gz: 1e7e6c583a9be88702d442f9da91921e0bb1debed9563af582f1e06d356cc575
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 9d3cc9a905b9ed10d597c8e2a414a1fe4d368c486cb80d0adb9751df1c594f745597b5edbfc0087780154df510691fb6b5de3147fdc5f06ef4eac5c1312e7478
         | 
| 7 | 
            +
              data.tar.gz: a04b4aa9f19c3dd7b6bf2dd555f35129c5a89b1432997f6e1e9b0c5ada57d3a558e0a8eb570d36fc81f89fea27cb00f0c8d3aa06568228d3a170d848d3f7d4d0
         | 
    
        data/lib/pronto/rustcov.rb
    CHANGED
    
    | @@ -3,11 +3,21 @@ require 'pronto' | |
| 3 3 | 
             
            module Pronto
         | 
| 4 4 | 
             
              class Rustcov < Runner
         | 
| 5 5 | 
             
                def run
         | 
| 6 | 
            -
                  one_message_per_file( | 
| 6 | 
            +
                  one_message_per_file(lcov_path)
         | 
| 7 7 | 
             
                end
         | 
| 8 8 |  | 
| 9 | 
            -
                 | 
| 10 | 
            -
             | 
| 9 | 
            +
                private
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                def lcov_path
         | 
| 12 | 
            +
                  ENV['PRONTO_RUSTCOV_LCOV_PATH'] || ENV['LCOV_PATH'] || 'target/lcov.info'
         | 
| 13 | 
            +
                end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                def pronto_files_limit
         | 
| 16 | 
            +
                  ENV['PRONTO_RUSTCOV_FILES_LIMIT']&.to_i || 5
         | 
| 17 | 
            +
                end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                def pronto_messages_per_file_limit
         | 
| 20 | 
            +
                  ENV['PRONTO_RUSTCOV_MESSAGES_PER_FILE_LIMIT']&.to_i || 5
         | 
| 11 21 | 
             
                end
         | 
| 12 22 |  | 
| 13 23 | 
             
                def one_message_per_file(lcov_path)
         | 
| @@ -15,9 +25,15 @@ module Pronto | |
| 15 25 |  | 
| 16 26 | 
             
                  lcov = parse_lcov(lcov_path)
         | 
| 17 27 |  | 
| 28 | 
            +
                  grouped = group_patches(@patches, lcov)
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                  build_messages(grouped)
         | 
| 31 | 
            +
                end
         | 
| 32 | 
            +
             | 
| 33 | 
            +
                def group_patches(patches, lcov)
         | 
| 18 34 | 
             
                  grouped = Hash.new { |h, k| h[k] = [] }
         | 
| 19 35 |  | 
| 20 | 
            -
                   | 
| 36 | 
            +
                  patches.sort_by { |patch| -patch.added_lines.count }.take(pronto_files_limit).each do |patch|
         | 
| 21 37 | 
             
                    next unless patch.added_lines.any?
         | 
| 22 38 | 
             
                    file_path = patch.new_file_full_path.to_s
         | 
| 23 39 | 
             
                    uncovered = lcov[file_path]
         | 
| @@ -30,40 +46,66 @@ module Pronto | |
| 30 46 | 
             
                    end
         | 
| 31 47 | 
             
                  end
         | 
| 32 48 |  | 
| 33 | 
            -
                  grouped | 
| 49 | 
            +
                  grouped
         | 
| 50 | 
            +
                end
         | 
| 51 | 
            +
             | 
| 52 | 
            +
                def build_messages(grouped)
         | 
| 53 | 
            +
                  messages = []
         | 
| 54 | 
            +
             | 
| 55 | 
            +
                  grouped.each do |patch, lines|
         | 
| 34 56 | 
             
                    linenos = lines.map(&:new_lineno).sort
         | 
| 35 | 
            -
                     | 
| 36 | 
            -
             | 
| 37 | 
            -
             | 
| 38 | 
            -
                     | 
| 39 | 
            -
             | 
| 40 | 
            -
             | 
| 41 | 
            -
             | 
| 42 | 
            -
                       | 
| 43 | 
            -
                      lines.first | 
| 44 | 
            -
             | 
| 45 | 
            -
                       | 
| 46 | 
            -
             | 
| 47 | 
            -
             | 
| 48 | 
            -
             | 
| 57 | 
            +
                    line_ranges = linenos.chunk_while { |i, j| j == i + 1 }.to_a
         | 
| 58 | 
            +
             | 
| 59 | 
            +
                    # If we have a message per file limit of N, then create N individual messages
         | 
| 60 | 
            +
                    # We'll take each range and create a separate message for it, up to the limit
         | 
| 61 | 
            +
                    line_ranges.each do |range|
         | 
| 62 | 
            +
                      message_text = format_message_text(range)
         | 
| 63 | 
            +
             | 
| 64 | 
            +
                      # Find the first line in this range for the message
         | 
| 65 | 
            +
                      first_line_in_range = lines.find { |line| line.new_lineno == range.first }
         | 
| 66 | 
            +
             | 
| 67 | 
            +
                      messages << Pronto::Message.new(
         | 
| 68 | 
            +
                        patch.new_file_path,
         | 
| 69 | 
            +
                        first_line_in_range,
         | 
| 70 | 
            +
                        :warning,
         | 
| 71 | 
            +
                        message_text,
         | 
| 72 | 
            +
                        nil,
         | 
| 73 | 
            +
                        self.class
         | 
| 74 | 
            +
                      )
         | 
| 75 | 
            +
             | 
| 76 | 
            +
                      # Stop if we've reached the limit of messages per file
         | 
| 77 | 
            +
                      break if messages.count { |m| m.path == patch.new_file_path } >= pronto_messages_per_file_limit
         | 
| 78 | 
            +
                    end
         | 
| 49 79 | 
             
                  end
         | 
| 80 | 
            +
             | 
| 81 | 
            +
                  messages
         | 
| 50 82 | 
             
                end
         | 
| 51 83 |  | 
| 52 | 
            -
                 | 
| 84 | 
            +
                def format_message_text(range)
         | 
| 85 | 
            +
                  # Format the range as "start–end" or just the number if it's a single line
         | 
| 86 | 
            +
                  formatted_range = range.size > 1 ? "#{range.first}–#{range.last}" : range.first.to_s
         | 
| 87 | 
            +
             | 
| 88 | 
            +
                  "⚠️ Test coverage is missing for lines: #{formatted_range}"
         | 
| 89 | 
            +
                end
         | 
| 53 90 |  | 
| 54 91 | 
             
                def parse_lcov(path)
         | 
| 55 92 | 
             
                  uncovered = Hash.new { |h, k| h[k] = [] }
         | 
| 56 93 | 
             
                  file = nil
         | 
| 57 94 |  | 
| 58 | 
            -
                   | 
| 59 | 
            -
                     | 
| 60 | 
            -
             | 
| 61 | 
            -
                       | 
| 62 | 
            -
             | 
| 63 | 
            -
                       | 
| 64 | 
            -
             | 
| 65 | 
            -
                       | 
| 95 | 
            +
                  begin
         | 
| 96 | 
            +
                    File.foreach(path) do |line|
         | 
| 97 | 
            +
                      case line
         | 
| 98 | 
            +
                      when /^SF:(.+)/
         | 
| 99 | 
            +
                        file = File.expand_path($1.strip)
         | 
| 100 | 
            +
                      when /^DA:(\d+),0$/
         | 
| 101 | 
            +
                        uncovered[file] << $1.to_i if file
         | 
| 102 | 
            +
                      when /^end_of_record/
         | 
| 103 | 
            +
                        file = nil
         | 
| 104 | 
            +
                      end
         | 
| 66 105 | 
             
                    end
         | 
| 106 | 
            +
                  rescue Errno::ENOENT
         | 
| 107 | 
            +
                    # File not found, raise a more informative error
         | 
| 108 | 
            +
                    fail "LCOV file not found at #{path}. Make sure your Rust tests were run with coverage enabled."
         | 
| 67 109 | 
             
                  end
         | 
| 68 110 |  | 
| 69 111 | 
             
                  uncovered
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: pronto-rustcov
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.1. | 
| 4 | 
            +
              version: 0.1.7
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Pavel Lazureykis
         | 
| 8 8 | 
             
            autorequire:
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2025-05- | 
| 11 | 
            +
            date: 2025-05-15 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: pronto
         | 
| @@ -24,6 +24,48 @@ dependencies: | |
| 24 24 | 
             
                - - ">="
         | 
| 25 25 | 
             
                  - !ruby/object:Gem::Version
         | 
| 26 26 | 
             
                    version: 0.11.0
         | 
| 27 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 28 | 
            +
              name: rspec
         | 
| 29 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 30 | 
            +
                requirements:
         | 
| 31 | 
            +
                - - "~>"
         | 
| 32 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 33 | 
            +
                    version: '3.12'
         | 
| 34 | 
            +
              type: :development
         | 
| 35 | 
            +
              prerelease: false
         | 
| 36 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 37 | 
            +
                requirements:
         | 
| 38 | 
            +
                - - "~>"
         | 
| 39 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 40 | 
            +
                    version: '3.12'
         | 
| 41 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 42 | 
            +
              name: rake
         | 
| 43 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 44 | 
            +
                requirements:
         | 
| 45 | 
            +
                - - "~>"
         | 
| 46 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 47 | 
            +
                    version: '13.0'
         | 
| 48 | 
            +
              type: :development
         | 
| 49 | 
            +
              prerelease: false
         | 
| 50 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 51 | 
            +
                requirements:
         | 
| 52 | 
            +
                - - "~>"
         | 
| 53 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 54 | 
            +
                    version: '13.0'
         | 
| 55 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 56 | 
            +
              name: simplecov
         | 
| 57 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 58 | 
            +
                requirements:
         | 
| 59 | 
            +
                - - "~>"
         | 
| 60 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 61 | 
            +
                    version: 0.22.0
         | 
| 62 | 
            +
              type: :development
         | 
| 63 | 
            +
              prerelease: false
         | 
| 64 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 65 | 
            +
                requirements:
         | 
| 66 | 
            +
                - - "~>"
         | 
| 67 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 68 | 
            +
                    version: 0.22.0
         | 
| 27 69 | 
             
            description: This gem integrates Rust test coverage with Pronto via LCOV.
         | 
| 28 70 | 
             
            email:
         | 
| 29 71 | 
             
            - pavel@lazureykis.dev
         | 
| @@ -44,7 +86,7 @@ required_ruby_version: !ruby/object:Gem::Requirement | |
| 44 86 | 
             
              requirements:
         | 
| 45 87 | 
             
              - - ">="
         | 
| 46 88 | 
             
                - !ruby/object:Gem::Version
         | 
| 47 | 
            -
                  version: '2 | 
| 89 | 
            +
                  version: '3.2'
         | 
| 48 90 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 49 91 | 
             
              requirements:
         | 
| 50 92 | 
             
              - - ">="
         |