Skip to content

Commit

Permalink
Fix check-string.sh to check every generated strings (#5179)
Browse files Browse the repository at this point in the history
The original implementation only checked lit-magic-strings.inc.h.
This patch adds checking for ecma-error-messages.inc.h and parser-error-messages.inc.h

This patch fixes #5172 issue.

JerryScript-DCO-1.0-Signed-off-by: Gergo Csizi [email protected]
  • Loading branch information
gergocs authored Nov 27, 2024
1 parent ba89576 commit 5f467a6
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
5 changes: 1 addition & 4 deletions jerry-core/ecma/base/ecma-error-messages.inc.h
Original file line number Diff line number Diff line change
Expand Up @@ -506,11 +506,8 @@ ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_THIS_NOT_GENERATOR_OBJECT, "Argument 'this' is
ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_CANNOT_CONVERT_TO_OBJECT, "Argument cannot be converted to an object")
#if JERRY_BUILTIN_BIGINT
ECMA_ERROR_DEF (ECMA_ERR_ALLOCATE_BIGINT_VALUE, "Cannot allocate memory for a BigInt value")
#endif /* JERRY_BUILTIN_BIGINT */
#if JERRY_BUILTIN_ATOMICS || JERRY_BUILTIN_BIGINT
ECMA_ERROR_DEF (ECMA_ERR_CONVERT_BIGINT_TO_NUMBER, "Cannot convert a BigInt value to a number")
#endif /* JERRY_BUILTIN_ATOMICS \
|| JERRY_BUILTIN_BIGINT */
#endif /* JERRY_BUILTIN_BIGINT */
ECMA_ERROR_DEF (ECMA_ERR_CONVERT_SYMBOL_TO_NUMBER, "Cannot convert a Symbol value to a number")
ECMA_ERROR_DEF (ECMA_ERR_CONVERT_SYMBOL_TO_STRING, "Cannot convert a Symbol value to a string")
#if JERRY_BUILTIN_BIGINT && JERRY_BUILTIN_TYPEDARRAY
Expand Down
31 changes: 27 additions & 4 deletions tools/check-strings.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,44 @@

MAGIC_STRINGS_GEN="tools/gen-strings.py"
MAGIC_STRINGS_INC_H="jerry-core/lit/lit-magic-strings.inc.h"
MAGIC_STRINGS_TEMP=`mktemp lit-magic-strings.inc.h.XXXXXXXXXX`
ECMA_ERROR_MESSAGES_INC_H="jerry-core/ecma/base/ecma-error-messages.inc.h"
PARSER_ERROR_MESSAGES_INC_H="jerry-core/parser/js/parser-error-messages.inc.h"
MAGIC_STRINGS_TEMP=$(mktemp lit-magic-strings.inc.h.XXXXXXXXXX)
ECMA_ERROR_MESSAGES_TEMP=$(mktemp ecma-error-messages.inc.h.XXXXXXXXXX)
PARSER_ERROR_MESSAGES_TEMP=$(mktemp parser-error-messages.inc.h.XXXXXXXXXX)

cp $MAGIC_STRINGS_INC_H $MAGIC_STRINGS_TEMP
cp $MAGIC_STRINGS_INC_H "$MAGIC_STRINGS_TEMP"
cp $ECMA_ERROR_MESSAGES_INC_H "$ECMA_ERROR_MESSAGES_TEMP"
cp $PARSER_ERROR_MESSAGES_INC_H "$PARSER_ERROR_MESSAGES_TEMP"
$MAGIC_STRINGS_GEN
DIFF_RESULT=$?

if [ $DIFF_RESULT -eq 0 ]
then
diff -q $MAGIC_STRINGS_INC_H $MAGIC_STRINGS_TEMP
diff -q $MAGIC_STRINGS_INC_H "$MAGIC_STRINGS_TEMP"
DIFF_RESULT=$?
if [ $DIFF_RESULT -ne 0 ]
then
echo -e "\e[1;33m$MAGIC_STRINGS_INC_H must be re-generated. Run $MAGIC_STRINGS_GEN\e[0m"
exit $DIFF_RESULT
fi
diff -q $ECMA_ERROR_MESSAGES_INC_H "$ECMA_ERROR_MESSAGES_TEMP"
DIFF_RESULT=$?
if [ $DIFF_RESULT -ne 0 ]
then
echo -e "\e[1;33m$ECMA_ERROR_MESSAGES_INC_H must be re-generated. Run $MAGIC_STRINGS_GEN\e[0m"
exit $DIFF_RESULT
fi
diff -q $PARSER_ERROR_MESSAGES_INC_H "$PARSER_ERROR_MESSAGES_TEMP"
DIFF_RESULT=$?
if [ $DIFF_RESULT -ne 0 ]
then
echo -e "\e[1;33m$PARSER_ERROR_MESSAGES_INC_H must be re-generated. Run $MAGIC_STRINGS_GEN\e[0m"
exit $DIFF_RESULT
fi
fi
mv $MAGIC_STRINGS_TEMP $MAGIC_STRINGS_INC_H
mv "$MAGIC_STRINGS_TEMP" $MAGIC_STRINGS_INC_H
mv "$ECMA_ERROR_MESSAGES_TEMP" $ECMA_ERROR_MESSAGES_INC_H
mv "$PARSER_ERROR_MESSAGES_TEMP" $PARSER_ERROR_MESSAGES_INC_H

exit $DIFF_RESULT

0 comments on commit 5f467a6

Please sign in to comment.