Skip to content
This repository has been archived by the owner on Aug 22, 2024. It is now read-only.

Commit

Permalink
feat: append match package v1
Browse files Browse the repository at this point in the history
  • Loading branch information
ASuciuX committed Nov 30, 2023
1 parent 97695b1 commit 717f2ce
Showing 1 changed file with 10 additions and 25 deletions.
35 changes: 10 additions & 25 deletions mutation-testing/scripts/append-match-package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ escape_for_awk() {
# Iterate over the specified files
for file in "${FILES[@]}"; do
pr_file="$PR_FOLDER/$file"
stable_file="$STABLE_FOLDER_PARENT/$file"

echo "Processing file: $file"

Expand All @@ -41,48 +40,34 @@ for file in "${FILES[@]}"; do
while IFS= read -r line; do
echo "Reading line from PR file: $line"

# Extract the core pattern without the line number and escape it for awk
# Extract the package from which the line is coming from
local_package=${$line%%/*}

# Extract the after the number line without the line number and escape it for awk
core_pattern=$(echo "$line" | sed -E 's/^[^:]+:[0-9]+:(.+)/\1/')
escaped_pattern=$(escape_for_awk "$core_pattern")
echo "Extracted and escaped pattern: $escaped_pattern"

# Iterate over each file in the STABLE folder
# Iterate over each file in the STABLE folder combined with local_package
for target_file in "${FILES[@]}"; do
target_path="$STABLE_FOLDER_PARENT/$target_file"
target_path="$STABLE_FOLDER_PARENT/$local_package/$target_file"
echo "Checking against STABLE file: $target_path"

# Remove the line matching the pattern, ignoring line numbers
awk -v pat="$escaped_pattern" '$0 !~ pat' "$target_path" > temp_file && mv temp_file "$target_path"
done

# Append PR line to the corresponding package and file
echo "$line" >> "$STABLE_FOLDER_PARENT/$local_package/$file"

done < "$pr_file"
else
echo "PR file $pr_file is empty or does not exist, skipping..."
fi
done

# After processing all lines, append contents from PR_DIR to STABLE_DIR
for file in "${FILES[@]}"; do
cat "$PR_FOLDER/$file" >> "$STABLE_FOLDER_PARENT/$file"
done

# Echo the contents of the STABLE folder for verification
echo "Updated contents of STABLE folder:"
for file in "${FILES[@]}"; do
stable_file="$STABLE_FOLDER_PARENT/$file"
echo "Contents of $stable_file:"
cat "$stable_file"
echo ""
done

echo "Script completed."




# goes only through txt




# remove temp/mutants.out
## rm -rf ../temp/

0 comments on commit 717f2ce

Please sign in to comment.