Skip to content

Commit c7b47e3

Browse files
committed
code coverage: implement JaCoCo report generation in CI (rev2)
1 parent a53cc39 commit c7b47e3

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

generate-jacoco-report.sh

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,26 +17,19 @@ fi
1717
# Ensure the report directory exists
1818
mkdir -p "$REPORT_DIR"
1919

20-
# Find all jacoco-ut.exec files dynamically
21-
EXEC_FILES=($(find "$PROJECT_ROOT" -name "jacoco-ut.exec" -type f))
20+
# Issue 1: Simplified find command (avoiding array initialization)
21+
EXEC_FILES=$(find "$PROJECT_ROOT" -name "jacoco-ut.exec" -type f)
2222

23-
# Check if any execution data files were found
24-
if [ ${#EXEC_FILES[@]} -eq 0 ]; then
23+
# Issue 2: Simplified check for empty results using -z
24+
if [ -z "$EXEC_FILES" ]; then
2525
echo "Error: No jacoco-ut.exec files found in $PROJECT_ROOT"
2626
exit 1
2727
fi
2828

29-
# Check if all execution data files exist
30-
for exec_file in "${EXEC_FILES[@]}"; do
31-
if [ ! -f "$exec_file" ]; then
32-
echo "Error: Execution data file not found at $exec_file"
33-
exit 1
34-
fi
35-
done
36-
3729
# Merge execution data files
3830
echo "Merging execution data files..."
39-
java -jar "$JACOCO_CLI_JAR" merge "${EXEC_FILES[@]}" --destfile "$MERGED_EXEC"
31+
# Issue 4: Passing the string directly
32+
java -jar "$JACOCO_CLI_JAR" merge ${EXEC_FILES} --destfile "$MERGED_EXEC"
4033

4134
if [ $? -ne 0 ]; then
4235
echo "Error: Failed to merge execution data files"
@@ -50,10 +43,11 @@ echo "Generating coverage report..."
5043
CLASSFILES_ARGS=()
5144
SOURCEFILES_ARGS=()
5245

53-
for exec_file in "${EXEC_FILES[@]}"; do
46+
# Issue 5: Iterating over the string list instead of an array
47+
for exec_file in ${EXEC_FILES}; do
5448
# Extract module path (e.g., core, dlm, rquota) from the exec file path
5549
module_path=$(dirname "$(dirname "$(dirname "$exec_file")")")
56-
module_name=$(basename "$module_path")
50+
5751
# Add classfiles and sourcefiles arguments
5852
CLASSFILES_ARGS+=("--classfiles" "$module_path/target/classes")
5953
SOURCEFILES_ARGS+=("--sourcefiles" "$module_path/src/main/java")

0 commit comments

Comments
 (0)