Skip to content

Commit

Permalink
compare-current-and-expected use set log paths
Browse files Browse the repository at this point in the history
Do not `find` on the fly, instead use set log files in file
compare-current-and-expected_logs.txt
  • Loading branch information
jtmoon79 committed Jan 9, 2023
1 parent 2975c9a commit 80d06dd
Show file tree
Hide file tree
Showing 4 changed files with 439 additions and 18,719 deletions.
31 changes: 16 additions & 15 deletions tools/compare-current-and-expected-update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ PROGRAM=${PROGRAM-./target/release/s4}
expect1=./tools/compare-current-and-expected_expected.out

if ! chmod +w -- "${expect1}"; then
echo "ERROR unable to remove wx from file '${expect1}'" >&2
echo "ERROR unable to write to file '${expect1}'" >&2
exit 1
fi

Expand All @@ -26,26 +26,23 @@ if ! touch "${expect1}"; then
exit 1
fi

logs=$(mktemp -t "tmp.s4.compare-current-and-expected_logs_XXXXX")

function exit_() {
rm -f -- "${logs}"
}
trap exit_ EXIT

path=./logs

# this file selection must agree with `compare-current-and-expected.sh`
(find "${path}" -xdev -type f -size -2M | sort) > "${logs}"

#
# print some info for the script user, verify the s4 program can run
#

echo >&2
logs='./tools/compare-current-and-expected_logs.txt'

if [[ ! -e "${logs}" ]]; then
echo "ERROR file does not exist '${logs}'" >&2
exit 1
elif [[ ! -r "${logs}" ]]; then
echo "ERROR file is not readable '${logs}'" >&2
exit 1
fi

cat "${logs}" >&2
echo >&2
echo "$(wc -l < "${logs}") files under \"${path}\"" >&2
echo "$(wc -l < "${logs}") files under \"${logs}\"" >&2
echo >&2

PROGRAM=${PROGRAM-./target/release/s4}
Expand All @@ -70,3 +67,7 @@ if ! chmod -wx -- "${expect1}"; then
echo "ERROR unable to remove wx from file '${expect1}'" >&2
exit 1
fi

echo >&2
echo "Updated file '${expect1}'" >&2
echo -e "Now run \e[1mcompare-current-and-expected.sh\e[0m." >&2
22 changes: 10 additions & 12 deletions tools/compare-current-and-expected.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,25 +35,23 @@ fi
# get list of files to process
#

logs=$(mktemp -t "tmp.s4.compare-current-and-expected_logs_XXXXX")
logs='./tools/compare-current-and-expected_logs.txt'

function exit_() {
rm -f -- "${logs}"
}
trap exit_ EXIT

path=./logs

(find "${path}" -xdev -type f -size -2M | sort) > "${logs}"
if [[ ! -e "${logs}" ]]; then
echo "ERROR file does not exist '${logs}'" >&2
exit 1
elif [[ ! -r "${logs}" ]]; then
echo "ERROR file is not readable '${logs}'" >&2
exit 1
fi

#
# print some info for the script user, verify the s4 program can run
#

echo >&2
cat "${logs}" >&2
echo >&2
echo "$(wc -l < "${logs}") files under \"${path}\"" >&2
echo "$(wc -l < "${logs}") files in \"${logs}\"" >&2
echo >&2

PROGRAM=${PROGRAM-./target/release/s4}
Expand Down Expand Up @@ -104,7 +102,7 @@ if ! diff --text --brief "${current1}" "${expect1}"; then
echo "Difference Preview:"
((set -x; diff --text -y --width=${COLUMNS-120} --suppress-common-lines "${current1}" "${expect1}") || true) | head -n 100
echo
echo "Do you need to run *compare-current-and-expected-update.sh*?"
echo -e "Do you need to run \e[1mcompare-current-and-expected-update.sh\e[0m ?"
echo
else
echo
Expand Down
Loading

0 comments on commit 80d06dd

Please sign in to comment.