Skip to content

Commit

Permalink
[CUBRIDQA-1242] Add sort option on compare_result_between_files method (
Browse files Browse the repository at this point in the history
#692)

* add sort option on compare_result_between_files method

http://jira.cubrid.org/browse/CUBRIDQA-1242

Usage:
compare_result_between_files file1 file2 [error | sort]
  • Loading branch information
tw-kang authored Dec 30, 2024
1 parent ff15750 commit add46cf
Showing 1 changed file with 38 additions and 6 deletions.
44 changes: 38 additions & 6 deletions CTP/shell/init_path/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ function diff_ignore_lineno

# After comparing two files, This function write the result int result files.
# Usage:
# compare_result_between_files file1 file2 [error]
# compare_result_between_files file1 file2 [error|sort]

function compare_result_between_files
{
Expand Down Expand Up @@ -374,27 +374,59 @@ function compare_result_between_files
dos2unix $right

echo "start to compare files: diff $left $right"
if [ "$3" = "error" ]
if [ "$3" = "error" ] && [ "$4" = "sort" ] || [ "$3" = "sort" ] && [ "$4" = "error" ]
then
sorted_left="${left}_sorted"
sorted_right="${right}_sorted"
sort $left > $sorted_left
sort $right > $sorted_right

if diff_ignore_lineno $sorted_left $sorted_right -b
then
write_nok
echo "diff $sorted_left $sorted_right failed" >> $result_file
diff_ignore_lineno $sorted_left $sorted_right -y |tee -a $result_file
else
write_ok
fi

rm -f $sorted_left $sorted_right
elif [ "$3" = "error" ]
then
if diff_ignore_lineno $left $right -b
then
write_nok
echo "diff $left $right failed" >> $result_file
#diff $left $right -y >> $result_file
diff_ignore_lineno $left $right -y |tee -a $result_file
diff_ignore_lineno $left $right -y |tee -a $result_file
else
write_ok
fi
let "answer_no = answer_no + 1"
elif [ "$3" = "sort" ]
then
sorted_left="${left}_sorted"
sorted_right="${right}_sorted"
sort $left > $sorted_left
sort $right > $sorted_right

if diff_ignore_lineno $sorted_left $sorted_right -b
then
write_ok
else
write_nok
echo "diff $sorted_left $sorted_right failed" >> $result_file
diff_ignore_lineno $sorted_left $sorted_right -y |tee -a $result_file
fi

rm -f $sorted_left $sorted_right
else
if diff_ignore_lineno $left $right -b
then
write_ok
else
write_nok
echo "diff $left $right failed" >> $result_file
#diff $left $right -y >> $result_file
diff_ignore_lineno $left $right -y |tee -a $result_file
diff_ignore_lineno $left $right -y |tee -a $result_file
fi
let "answer_no = answer_no + 1"
fi
Expand Down

0 comments on commit add46cf

Please sign in to comment.