Skip to content

Commit

Permalink
Windows fixes to compare_compilers.sh (#305)
Browse files Browse the repository at this point in the history
  • Loading branch information
Akuli authored Mar 6, 2023
1 parent ae8405f commit b52b316
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions compare_compilers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ mkdir -vp tmp/compare_compilers

echo "Compiling the self-hosted compiler..."
if [[ "$OS" =~ Windows ]]; then
make self_hosted_compiler.exe
mingw32-make self_hosted_compiler.exe
else
make self_hosted_compiler
fi
Expand All @@ -45,12 +45,18 @@ for action in tokenize parse run; do
(./jou $flag $file || true) &> tmp/compare_compilers/compiler_written_in_c.txt
(./self_hosted_compiler $flag $file || true) &> tmp/compare_compilers/self_hosted.txt

if grep -qxF $file $error_list_file; then
if grep -q '\r' $error_list_file; then
newline=crlf
else
newline=lf
fi

if grep -qxF $file <(cat $error_list_file | tr -d '\r'); then
# The file is skipped, so the two compilers should behave differently
if diff tmp/compare_compilers/compiler_written_in_c.txt tmp/compare_compilers/self_hosted.txt >/dev/null; then
if [ $fix = yes ]; then
echo " Deleting $file from $error_list_file"
grep -vxF $file $error_list_file > tmp/compare_compilers/newlist.txt
grep -vxF $file <(cat $error_list_file | tr -d '\r') > tmp/compare_compilers/newlist.txt
mv tmp/compare_compilers/newlist.txt $error_list_file
else
echo " Error: Compilers behave the same even though the file is listed in $error_list_file."
Expand All @@ -75,6 +81,11 @@ for action in tokenize parse run; do
fi
fi
fi

if [ $newline = crlf ] && [ $fix = yes ]; then
# Some of the edits (e.g. appending with echo) leave LF line endings
unix2dos -q $error_list_file
fi
done
done

Expand Down

0 comments on commit b52b316

Please sign in to comment.