Skip to content

Instantly share code, notes, and snippets.

@z-turk3
Last active March 28, 2021 14:11
Show Gist options
  • Select an option

  • Save z-turk3/4e263fc285f6e171f92d6acc9d69455e to your computer and use it in GitHub Desktop.

Select an option

Save z-turk3/4e263fc285f6e171f92d6acc9d69455e to your computer and use it in GitHub Desktop.

Revisions

  1. z-turk3 revised this gist Feb 10, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion xccov-to-sonarqube-generic.sh
    Original file line number Diff line number Diff line change
    @@ -18,7 +18,7 @@ function xccov_to_generic {
    echo '<coverage version="1">'
    for xccovarchive_file in "$@"; do
    local xccov_options=""
    if [[ $xccovarchive_file == *".xcresult"* ]]; then
    if [[ $xccovarchive_file == *".xcresult/" ]]; then
    xccov_options="--archive"
    fi
    xcrun xccov view $xccov_options --file-list "$xccovarchive_file" | while read -r file_name; do
  2. z-turk3 revised this gist Feb 8, 2020. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion xccov-to-sonarqube-generic.sh
    Original file line number Diff line number Diff line change
    @@ -21,7 +21,6 @@ function xccov_to_generic {
    if [[ $xccovarchive_file == *".xcresult"* ]]; then
    xccov_options="--archive"
    fi

    xcrun xccov view $xccov_options --file-list "$xccovarchive_file" | while read -r file_name; do
    if [[ $file_name == *" "* ]]; then
    continue
  3. z-turk3 revised this gist Feb 8, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion xccov-to-sonarqube-generic.sh
    Original file line number Diff line number Diff line change
    @@ -32,7 +32,7 @@ function xccov_to_generic {
    if [[ $file_name == *".m" ]] || [[ $file_name == *".h" ]]; then
    continue
    fi
    convert_file "$xccovarchive_file" "$file_name"
    convert_file "$xccovarchive_file" "$file_name" "$xccov_options"
    done
    done
    echo '</coverage>'
  4. z-turk3 revised this gist Feb 7, 2020. 1 changed file with 8 additions and 2 deletions.
    10 changes: 8 additions & 2 deletions xccov-to-sonarqube-generic.sh
    Original file line number Diff line number Diff line change
    @@ -4,8 +4,9 @@ set -euo pipefail
    function convert_file {
    local xccovarchive_file="$1"
    local file_name="$2"
    local xccov_options="$3"
    echo " <file path=\"$file_name\">"
    xcrun xccov view --file "$file_name" "$xccovarchive_file" | \
    xcrun xccov view $xccov_options --file "$file_name" "$xccovarchive_file" | \
    sed -n '
    s/^ *\([0-9][0-9]*\): 0.*$/ <lineToCover lineNumber="\1" covered="false"\/>/p;
    s/^ *\([0-9][0-9]*\): [1-9].*$/ <lineToCover lineNumber="\1" covered="true"\/>/p
    @@ -16,7 +17,12 @@ function convert_file {
    function xccov_to_generic {
    echo '<coverage version="1">'
    for xccovarchive_file in "$@"; do
    xcrun xccov view --file-list "$xccovarchive_file" | while read -r file_name; do
    local xccov_options=""
    if [[ $xccovarchive_file == *".xcresult"* ]]; then
    xccov_options="--archive"
    fi

    xcrun xccov view $xccov_options --file-list "$xccovarchive_file" | while read -r file_name; do
    if [[ $file_name == *" "* ]]; then
    continue
    fi
  5. z-turk3 revised this gist Aug 22, 2019. 1 changed file with 2 additions and 5 deletions.
    7 changes: 2 additions & 5 deletions xccov-to-sonarqube-generic.sh
    Original file line number Diff line number Diff line change
    @@ -23,10 +23,7 @@ function xccov_to_generic {
    if [[ $file_name == *"/Pods/"* ]]; then
    continue
    fi
    if [[ $file_name == *".m" ]]; then
    continue
    fi
    if [[ $file_name == *".h" ]]; then
    if [[ $file_name == *".m" ]] || [[ $file_name == *".h" ]]; then
    continue
    fi
    convert_file "$xccovarchive_file" "$file_name"
    @@ -35,4 +32,4 @@ function xccov_to_generic {
    echo '</coverage>'
    }

    xccov_to_generic "$@"
    xccov_to_generic "$@"
  6. z-turk3 created this gist Aug 22, 2019.
    38 changes: 38 additions & 0 deletions xccov-to-sonarqube-generic.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,38 @@
    #!/usr/bin/env bash
    set -euo pipefail

    function convert_file {
    local xccovarchive_file="$1"
    local file_name="$2"
    echo " <file path=\"$file_name\">"
    xcrun xccov view --file "$file_name" "$xccovarchive_file" | \
    sed -n '
    s/^ *\([0-9][0-9]*\): 0.*$/ <lineToCover lineNumber="\1" covered="false"\/>/p;
    s/^ *\([0-9][0-9]*\): [1-9].*$/ <lineToCover lineNumber="\1" covered="true"\/>/p
    '
    echo ' </file>'
    }

    function xccov_to_generic {
    echo '<coverage version="1">'
    for xccovarchive_file in "$@"; do
    xcrun xccov view --file-list "$xccovarchive_file" | while read -r file_name; do
    if [[ $file_name == *" "* ]]; then
    continue
    fi
    if [[ $file_name == *"/Pods/"* ]]; then
    continue
    fi
    if [[ $file_name == *".m" ]]; then
    continue
    fi
    if [[ $file_name == *".h" ]]; then
    continue
    fi
    convert_file "$xccovarchive_file" "$file_name"
    done
    done
    echo '</coverage>'
    }

    xccov_to_generic "$@"