Skip to content

Commit

Permalink
Introduce merge_junit script
Browse files Browse the repository at this point in the history
To improve performance of Android unit tests collection. Originated it woocommerce/woocommerce-android#12064
  • Loading branch information
wzieba committed Aug 2, 2024
1 parent abdf292 commit 3c5ffa1
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/a8c-ci-toolkit-buildkite-plugin.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 40 additions & 0 deletions bin/merge_junit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash

# Initialize variables
reports_dir=""
output_file=""

# Function to show usage
usage() {
echo "Usage: $0 -d <reports_dir> -o <output_file>"
exit 1
}

# Parse command-line options
while getopts "d:o:" opt; do
case $opt in
d) reports_dir=$OPTARG ;;
o) output_file=$OPTARG ;;
?) usage ;;
esac
done

# Check if both arguments were provided
if [ -z "$reports_dir" ] || [ -z "$output_file" ]; then
usage
fi

# Write XML header to the output file
echo '<?xml version="1.0" encoding="UTF-8"?>' > "$output_file"
echo '<testsuites>' >> "$output_file"

# Merge the content of all input JUnit files in the directory.
# (Note that in the case of Unit Tests, the JUnit XML files produced by Gradle
# don't have a parent `<testsuites>` root tag, so there's no need to try and remove it)
sed '/<\?xml .*\?>/d' "$reports_dir"/*.xml >> "$output_file"

# Close the testsuites tag
echo '</testsuites>' >> "$output_file"

# Print the result
echo "Merged XML reports into $output_file"

0 comments on commit 3c5ffa1

Please sign in to comment.