wxwidgets library tests: Add syntax checking, fix test file. (#1084)
For the syntax check g++ needs to know the wxWidgets include paths which are retrieved via wx-config. If includes are missing or not working the syntax check is skipped. wxwidgets.cpp: Fixed syntax, includes and added code so the syntax check does not fail if some special features are not present.
This commit is contained in:
parent
e0e664f996
commit
170d60712f
|
@ -45,6 +45,22 @@ ${CPPCHECK} ${CPPCHECK_OPT} --inconclusive --platform=win32W ${DIR}windows.cpp
|
||||||
${CPPCHECK} ${CPPCHECK_OPT} --inconclusive --platform=win64 ${DIR}windows.cpp
|
${CPPCHECK} ${CPPCHECK_OPT} --inconclusive --platform=win64 ${DIR}windows.cpp
|
||||||
|
|
||||||
# wxwidgets.cpp
|
# wxwidgets.cpp
|
||||||
# Syntax check via g++ is disabled because wx headers are not always present.
|
set +e
|
||||||
#${CXX} ${CXX_OPT} ${DIR}wxwidgets.cpp
|
WXCONFIG=`wx-config --cxxflags`
|
||||||
${CPPCHECK} ${CPPCHECK_OPT} --inconclusive --library=wxwidgets ${DIR}wxwidgets.cpp
|
WXCONFIG_RETURNCODE=$?
|
||||||
|
set -e
|
||||||
|
if [ $WXCONFIG_RETURNCODE -ne 0 ]; then
|
||||||
|
echo "wx-config does not work, skipping syntax check for wxWidgets tests."
|
||||||
|
else
|
||||||
|
set +e
|
||||||
|
echo -e "#include <wx/filefn.h>\n#include <wx/app.h>\n#include <wx/artprov.h>\n" | ${CXX} ${CXX_OPT} ${WXCONFIG} -x c++ -
|
||||||
|
WXCHECK_RETURNCODE=$?
|
||||||
|
set -e
|
||||||
|
if [ $WXCHECK_RETURNCODE -ne 0 ]; then
|
||||||
|
echo "wxWidgets not completely present (with GUI classes) or not working, skipping syntax check with ${CXX}."
|
||||||
|
else
|
||||||
|
echo "wxWidgets found, checking syntax with ${CXX} now."
|
||||||
|
${CXX} ${CXX_OPT} ${WXCONFIG} -Wno-deprecated-declarations ${DIR}wxwidgets.cpp
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
${CPPCHECK} ${CPPCHECK_OPT} --inconclusive --library=wxwidgets -f ${DIR}wxwidgets.cpp
|
||||||
|
|
|
@ -7,7 +7,15 @@
|
||||||
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
|
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
|
||||||
//
|
//
|
||||||
|
|
||||||
|
#include <wx/app.h>
|
||||||
|
#include <wx/log.h>
|
||||||
#include <wx/filefn.h>
|
#include <wx/filefn.h>
|
||||||
|
#include <wx/spinctrl.h>
|
||||||
|
#include <wx/artprov.h>
|
||||||
|
#include <wx/calctrl.h>
|
||||||
|
#include <wx/combo.h>
|
||||||
|
#include <wx/icon.h>
|
||||||
|
#include <wx/bitmap.h>
|
||||||
|
|
||||||
void validCode()
|
void validCode()
|
||||||
{
|
{
|
||||||
|
@ -16,20 +24,28 @@ void validCode()
|
||||||
wxLogGeneric(wxLOG_Message, "test %d", 0);
|
wxLogGeneric(wxLOG_Message, "test %d", 0);
|
||||||
wxLogMessage("test %s", "str");
|
wxLogMessage("test %s", "str");
|
||||||
|
|
||||||
wxSpinCtrl::SetBase(10);
|
|
||||||
wxSpinCtrl::SetBase(16);
|
|
||||||
|
|
||||||
wxString translation1 = _("text");
|
wxString translation1 = _("text");
|
||||||
wxString translation2 = wxGetTranslation("text");
|
wxString translation2 = wxGetTranslation("text");
|
||||||
wxString translation3 = wxGetTranslation("string", "domain");
|
wxString translation3 = wxGetTranslation("string", "domain");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if wxUSE_GUI==1
|
||||||
|
void validGuiCode()
|
||||||
|
{
|
||||||
|
#if wxUSE_SPINCTRL==1
|
||||||
|
extern wxSpinCtrl spinCtrlInstance;
|
||||||
|
spinCtrlInstance.SetBase(10);
|
||||||
|
spinCtrlInstance.SetBase(16);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void nullPointer()
|
void nullPointer()
|
||||||
{
|
{
|
||||||
// cppcheck-suppress nullPointer
|
// cppcheck-suppress nullPointer
|
||||||
wxLogGeneric(wxLOG_Message, NULL);
|
wxLogGeneric(wxLOG_Message, (char*)NULL);
|
||||||
// cppcheck-suppress nullPointer
|
// cppcheck-suppress nullPointer
|
||||||
wxLogMessage(NULL);
|
wxLogMessage((char*)NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ignoredReturnValue()
|
void ignoredReturnValue()
|
||||||
|
@ -40,10 +56,13 @@ void ignoredReturnValue()
|
||||||
|
|
||||||
void invalidFunctionArg()
|
void invalidFunctionArg()
|
||||||
{
|
{
|
||||||
|
#if wxUSE_SPINCTRL==1
|
||||||
|
extern wxSpinCtrl spinCtrlInstance;
|
||||||
// cppcheck-suppress invalidFunctionArg
|
// cppcheck-suppress invalidFunctionArg
|
||||||
wxSpinCtrl::SetBase(0);
|
spinCtrlInstance.SetBase(0);
|
||||||
// cppcheck-suppress invalidFunctionArg
|
// cppcheck-suppress invalidFunctionArg
|
||||||
wxSpinCtrl::SetBase(5);
|
spinCtrlInstance.SetBase(5);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void uninitvar()
|
void uninitvar()
|
||||||
|
@ -61,14 +80,20 @@ void uninitvar()
|
||||||
|
|
||||||
void deprecatedFunctions(wxApp &a, const wxString &s, wxArtProvider *artProvider, wxCalendarCtrl &calenderCtrl, wxComboCtrl &comboCtrl)
|
void deprecatedFunctions(wxApp &a, const wxString &s, wxArtProvider *artProvider, wxCalendarCtrl &calenderCtrl, wxComboCtrl &comboCtrl)
|
||||||
{
|
{
|
||||||
|
#ifdef __WXOSX__
|
||||||
// cppcheck-suppress MacOpenFileCalled
|
// cppcheck-suppress MacOpenFileCalled
|
||||||
a.MacOpenFile(s);
|
a.MacOpenFile(s);
|
||||||
|
#endif
|
||||||
// cppcheck-suppress InsertCalled
|
// cppcheck-suppress InsertCalled
|
||||||
wxArtProvider::Insert(artProvider);
|
wxArtProvider::Insert(artProvider);
|
||||||
|
#if defined(__WXMSW__) || defined(__WXGTK__)
|
||||||
|
// EnableYearChange() is not available on these GUI systems
|
||||||
|
#else
|
||||||
// cppcheck-suppress EnableYearChangeCalled
|
// cppcheck-suppress EnableYearChangeCalled
|
||||||
calenderCtrl.EnableYearChange(false);
|
calenderCtrl.EnableYearChange(false);
|
||||||
// cppcheck-suppress EnableYearChangeCalled
|
// cppcheck-suppress EnableYearChangeCalled
|
||||||
calenderCtrl.EnableYearChange(/*default=yes*/);
|
calenderCtrl.EnableYearChange(/*default=yes*/);
|
||||||
|
#endif
|
||||||
// cppcheck-suppress GetTextIndentCalled
|
// cppcheck-suppress GetTextIndentCalled
|
||||||
// cppcheck-suppress ignoredReturnValue
|
// cppcheck-suppress ignoredReturnValue
|
||||||
comboCtrl.GetTextIndent();
|
comboCtrl.GetTextIndent();
|
||||||
|
|
Loading…
Reference in New Issue