Commit 260cebc8 authored by Ronan Abhamon's avatar Ronan Abhamon

feat(app): add new tool `test_qml` that run unit tests on all `*.spec.qml` files

parent 0e12f049
......@@ -96,7 +96,7 @@ endforeach ()
add_custom_target(
check_qml DEPENDS ${QML_SOURCES}
COMMAND "${CMAKE_SOURCE_DIR}/tools/check_qml"
COMMAND "${CMAKE_SOURCE_DIR}/tools/check_qml_syntax"
)
# --------------------------------------------------------------------
......
<!DOCTYPE RCC><RCC version="1.0">
<qresource prefix="/">
<qresource prefix="">
<file>imgs/add_field.svg</file>
<file>imgs/call.svg</file>
<file>imgs/cam.svg</file>
......@@ -32,6 +32,7 @@
<file>ui/modules/Common/Colors.qml</file>
<file>ui/modules/Common/Constants.qml</file>
<file>ui/modules/Common/Dialog/ConfirmDialog.qml</file>
<file>ui/modules/Common/Dialog/ConfirmDialog.spec.qml</file>
<file>ui/modules/Common/Dialog/DialogDescription.qml</file>
<file>ui/modules/Common/Dialog/DialogPlus.qml</file>
<file>ui/modules/Common/DroppableTextArea.qml</file>
......
......@@ -4,7 +4,7 @@
# Tool to check the syntax of `.qml`/`.js` files.
# ====================================================================
RESOURCES_FILE="resources.qrc"
RESOURCES_FILE='resources.qrc'
LINTER=qmllint-qt5
RED='\e[1;31m'
......
#!/usr/bin/sh
RED='\e[1;31m'
GREEN='\e[1;32m'
BLUE='\e[1;34m'
NC='\e[0m'
# Check QML files, quit on failure.
sh "./tests/tools/check_qml"
sh './tests/tools/check_qml_syntax'
if [[ $? != 0 ]] ; then
exit 1
fi
# Check JS lib.
printf "${BLUE}Testing scripts lib...${NC}\n"
so_far_so_good=0
qmltestrunner -input "./tests/ui/scripts/Utils/utils.spec.qml"
printf '\n'
if [[ $? == 0 ]]; then
printf "${GREEN}Done. No error found in scripts lib.\n"
else
printf "${RED}One or more errors were found. Please to fix them.\n"
so_far_so_good=1
fi
printf "${NC}"
# Run unit tests.
sh './tests/tools/test_qml'
exit $so_far_so_good
exit $?
#!/usr/bin/sh
RESOURCES_FILE='resources.qrc'
TEST_RUNNER='qmltestrunner-qt5'
TEST_FILE_EXTENSION='spec.qml'
RED='\e[1;31m'
GREEN='\e[1;32m'
BLUE='\e[1;34m'
NC='\e[0m'
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $SCRIPT_DIR/..
# Check JS lib.
printf "${BLUE}Testing scripts lib...${NC}\n"
so_far_so_good=0
$TEST_RUNNER -input './ui/scripts/Utils/utils.spec.qml'
if [[ $? == 0 ]]; then
printf "${GREEN}Done. No error found in scripts lib.\n"
else
printf "${RED}One or more errors were found. Please to fix them.\n"
so_far_so_good=1
fi
printf "${NC}\n"
# Check all `*.spec.qml` files
while read line
do
qml_file=$(
printf "$line" |
sed -n 's/^\s*<\s*file\s*>\s*\(.*\.qml\)\s*<\s*\/\s*file\s*>\s*$/\1/p'
)
if [[ ! -z $qml_file ]]; then
spec_qml_file="${qml_file%.*}.${TEST_FILE_EXTENSION}"
if [ -f $spec_qml_file ]; then
printf "${BLUE}Running unit qml tests of '${qml_file}'...${NC}\n"
$TEST_RUNNER -import './ui/modules/' -input "$spec_qml_file"
if [[ $? == 0 ]]; then
printf "${GREEN}All unit tests have succeeded for '${spec_qml_file}'.\n"
else
printf "${RED}Unit tests have failed for '${spec_qml_file}'.\n"
so_far_so_good=1
fi
fi
fi
done < $RESOURCES_FILE
printf "\n"
if [[ $so_far_so_good == 0 ]]; then
printf "${GREEN}Done. All tests have succeeded.\n"
else
printf "${RED}Fail. One or many tests have failed.\n"
so_far_so_good=1
fi
printf "${NC}\n"
exit $so_far_so_good
......@@ -10,13 +10,13 @@
# If you don't want to add a particular file, do not use this script!
# ====================================================================
RESOURCES_FILE="resources.qrc"
RESOURCES_FILE='resources.qrc'
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $SCRIPT_DIR/..
echo "<!DOCTYPE RCC><RCC version=\"1.0\">
<qresource prefix=\"/\">" > $RESOURCES_FILE
echo '<!DOCTYPE RCC><RCC version="1.0">
<qresource prefix="/">' > $RESOURCES_FILE
for filename in $(find ui/ imgs/ -type f | sort)
do
......@@ -29,5 +29,5 @@ do
fi
done
echo " </qresource>
</RCC>" >> $RESOURCES_FILE
echo ' </qresource>
</RCC>' >> $RESOURCES_FILE
......@@ -26,7 +26,6 @@ TestCase {
return dialog
}
function test_exitStatusViaButtons_data () {
return [
{ button: 0, expectedStatus: 0 },
......
pragma Singleton
import QtQuick 2.7
import Common.Styles 1.0
import Common 1.0
// ===================================================================
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment