Skip to content

Commit

Permalink
add fix test names script
Browse files Browse the repository at this point in the history
  • Loading branch information
PgBiel committed Aug 26, 2024
1 parent 75fa91a commit 3a45514
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions bin/glistix-fix-test-names.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/sh
# Replaces 'gleam_core__' with 'glistix_core__' before all test snapshot (.snap) names
# Has some additional code to make it pretty because why not

ANSI_BOLD=$'\e[1m'
ANSI_BLUE=$'\e[34m'
ANSI_GREEN=$'\e[32m'
ANSI_YELLOW=$'\e[33m'
ANSI_END=$'\e[0m'

echo "${ANSI_BOLD}=== Replacing 'gleam_core__' with 'glistix_core__' in test snapshot names ===${ANSI_END}" >&2

curr_dir=""
files=$(find . -name 'gleam_core__*.snap')
IFS=$'\n'
for i in ${files}
do
# Replace the prefix
newname="$(echo "$i" | sed -Ee 's;(^|/)gleam_core__;\1glistix_core__;')"

# --- Display info ---
dir="$(dirname "$i")"
if [ "$curr_dir" != "$dir" ]; then
echo "" >&2
echo "${ANSI_BLUE}*${ANSI_END} Directory ${ANSI_YELLOW}${ANSI_BOLD}${dir}${ANSI_END}:" >&2
curr_dir="$dir"
fi
echo " ${ANSI_BLUE}*${ANSI_END} Renaming ${ANSI_GREEN}${ANSI_BOLD}$(basename "${i}")${ANSI_END} -> ${ANSI_GREEN}${ANSI_BOLD}$(basename "${newname}")${ANSI_END}." >&2
# --------------------

# Move it!
mv "$i" -T "$newname"
done

# --- Display info ---
echo "" >&2
echo "${ANSI_BOLD}=== Renamed $(printf "${files}" | wc -l) files ===${ANSI_END}" >&2

0 comments on commit 3a45514

Please sign in to comment.