
#
# For further details regarding this file,
# see https://www.vtk.org/Wiki/CMake_Testing_With_CTest#Customizing_CTest
#

set(CTEST_CUSTOM_COVERAGE_EXCLUDE
  ${CTEST_CUSTOM_COVERAGE_EXCLUDE}

  # Exclude try_compile sources from coverage results:
  "/CMakeFiles/CMakeTmp/"

  # Exclude files generated by the moc pre-compiler
  ".*/moc_.*"

  # Exclude files generated by the uic pre-compiler
  ".*/ui_.*"

  # Exclude files generated by the resource pre-compiler
  ".*/qrc_.*"

  # Exclude files from the Testing directories
  ".*/Testing/.*"

  # Exclude generated python files
  ".*Python.cxx"
  ".*PythonInit.cxx"

  # Exclude Qt Designer plugins
  ".*/DesignerPlugins/.*"

  # Exclude generated cpp files
  ".*/generated_cpp/.*"

  )

# The following tests should not be run under valgrind
set(CTEST_CUSTOM_MEMCHECK_IGNORE

  )

set(CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS   1000)
set(CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS 1000)

set(CTEST_CUSTOM_WARNING_EXCEPTION
  ${CTEST_CUSTOM_WARNING_EXCEPTION}
  #"vtkparse.tab.c"
  "Microsoft SDKs."
  "VC.include."

  # qt suppressions from vtk...
  # Some Slicer dashboards include building bits of Qt which produce lots of
  # the following warnings when built with the MS compilers. Qt guys should
  # fix their code. Until they do, keep the Qt chatter off the Slicer dashboard
  # results:
  "[Qq]t([Cc]ore|[Gg]ui).*(warning|note)"
  "[Qq]t.*h.*warning.*declaration of .* shadows a member of .this"
  "[Qq]t.*h.*warning.*(copy constructor|assignment operator) could not be generated"
  "warning C4244: 'initializing' : conversion from 'qint64' to 'int', possible loss of data"
  # gcc -Wstric-aliasing
  "[Qq]t.*q.*h.*warning: dereferencing pointer .* does break strict-aliasing rules"
  "[Qq]t.*q.*h.*note: initialized from here"
  "[Qq]t.*q.*h.*note: while compiling"
  "[Qq]t.*q.*h.*note: see reference"
  "[Qq]t.*ui_"
  "[Qq]t.*note: see reference"
  "[Qq]t.*warning C4714"
  # Suppress warning caused when Qt 'foreach' loops are combined
  ".*warning: declaration of '_container_' shadows a previous local"

  # Make
  "warning: jobserver unavailable"
  "warning: -jN forced in submake: disabling jobserver mode."

  # Ignore method call with return value unused
  "declared with attribute warn_unused_result"

  # Windows: Ignore warning on Windows for static builds complaining that the archive has
  # no public symbols and hence will be inaccessible.
  "warning LNK4221"

  # Suppressing warnings about duplicate libraries in Darwin
  # At some point this may be addressed by CMake feature request:
  # https://public.kitware.com/Bug/view.php?id=10179
  "ld: warning: duplicate dylib"

  # Suppressing warnings about GL_GLEXT_LEGACY, the link reported below
  # report a similar problem with GL_GLEXT_PROTOTYPE.
  # https://lists.apple.com/archives/mac-opengl/2009/Dec/msg00081.html
  # That problem could be solved installing a newer version of X11 SDK
  # See https://xquartz.macosforge.org/trac/changeset/343
  ".*warning.*GL_GLEXT_LEGACY.*redefined"

  # ITK suppressions
  "[Uu]tilities.gdcm"
  "[Uu]tilities.vxl"
  "[Uu]tilities.itktiff"

  # VTK suppressions
  "vtkfreetype"
  "vtkkwiml.*old-style-cast"
  "Utilities.vtktiff"
  "VTK.*IO.vtkMySQLQuery.cxx"
  "VTK.*Utilities.vtkexodus2"
  "VTK.*Utilities.vtklibproj"
  "VTK.*Utilities.vtksqlite"
  "VTK.*Utilities.VPIC.*cxx"
  "VTK.*warn_unused_result"
  "VTK.*Filtering.*cxx"
  "VTK.*IO.*cxx"
  "VTK.*Infovis.*cxx"
  # exception specific to Mac/Carbon
  "VTK.Rendering.vtkCarbonRenderWindow.*warning.*(NewRgn|DiffRgn|EqualRgn|DisposeRgn).*is deprecated"
  # exception specific to Mac/X11
  "VTK.Rendering.vtkOpenGL.*warning: this is the location of the previous definition"
  # Windows: warning C4910: 'vtkImageIterator' : '__declspec(dllexport)' and 'extern' are incompatible on an explicit instantiation
  "Common.DataModel.vtkImageIterator.h.*warning C4910"

  # bzip2
  "bzip2.blocksort.c.*Winline"

  # CTK
  "moc_ctkTransferFunctionBarsItem.cxx.*old-style-cast"

  # CTK - dcmtk
  "dcmdata/dcovlay.h:93: warning: use of old-style cast"
  "/usr/bin/ranlib: .*lib(dcmtls|oflog).a.*has no symbols"
  "ld.*has different visibility.*(libdcmdata|libdcmnet|libdcmimgle|liboflog|libofstd).a"
  "DCMTK.(ofstd|dcmdata|dcmjpls|dcmnet|dcmimage|dcmimgle|dcmpstat|dcmqrdb).(lib|include|apps).*conversion from '(size_t|SOCKET)' to '.*', possible loss of data"

  # JsonCpp
  "json.(reader|value).h.*warning C4275.*non dll-interface class"

  # Libs/tclap
  "tclap.include.tclap.*Arg.h.*warning C4512"

  # Lua - SimpleITK-build/Lua-prefix/src/Lua/src/lauxlib.c:577:61: warning: while loop has empty body [-Wempty-body]
  "src.Lua.src.lauxlib"

  # Swig
  "Swig.Source"

  # Teem
  # Windows - warning C4244: 'function' : conversion from 'size_t' to 'double'
  "teem.src.*C4244"
  # Mac - teem/src/nrrd/superset.c:433: warning: format '%d' expects type 'int', but argument 6 has type 'ptrdiff_t'
  "teem.src.nrrd.superset.c.*warning"

  # Python
  "UserWarning:"

  # Python (posixmodule)
  "warning: the use of .tmpnam. is dangerous, better use .mkstemp."
  "warning: the use of .tmpnam_r. is dangerous, better use .mkstemp."

  # Python - Windows
  "(P|p)ython-3.6.7.(M|m)odules"
  "(P|p)ython-3.6.7.PC"
  "Include\\um\\winsock2.h.*warning C4005: 'INVALID_SOCKET': macro redefinition"
  # Python - Linux
  "Objects.unicodeobject.c.*warning:.*differ in signedness"
  "[Ii]nclude.(string|unicodeobject).h.*note: expected ‘const char *’ but argument is of type ‘unsigned char *’"
  "Modules.expat.xmlparse.*warning.*discards qualifiers from pointer target type"
  "Objects.stringobject.c.*uninitialized"
  # Python - Mac
  "ranlib: file:.*libpython3.6.a.*has no symbols"
  "python.Modules._cursesmodule.c.*warning.*may be used uninitialized in this function"
  "python.Mac.Modules.(cf|Nav).*warning: (cast|unused)"
  "python.Modules._ctypes.*warning: function declaration isn't a prototype"
  "QuickTime.framework.QuickTime, missing required architecture x86_64 in file"
  "python.Modules._ssl.*incompatible pointer type"
  "python.Mac.Modules.carbonevt.*defined but not used"
  "python.Mac.Modules.qt._Qtmodule.*used uninitialized in this function"
  "Modules.main.c.*warning: format not a string literal and no format arguments"
  # About redefinition of symbols
  "pyconfig.h.*warning:.*redefined"
  "features.h.*"

  # python packages
  "warning: no previously-included files.*matching.*distribution"
  "warning: no files found matching"
  "warnings.warn.msg"

  # curl suppressions
  "cmcurl.*warning.*conditional expression is constant"
  "cmcurl.*warning.*conversion from.*possible loss of data"
  # C4701: potentially uninitialized local variable '...' used
  # C4057: 'function' : '...' differs in indirection to slightly different base types from '...'
  # C4245: '=' : conversion from '...' to '...', signed/unsigned mismatch
  # C4706: assignment within conditional expression
  # C4232: nonstandard extension used : '...' : address of dllimport '...' is not static, identity not guaranteed
  "cmcurl.(transfer|ftp|file|cookie|url|telnet|multi|hostip4|formdata|easy).c.*warning (C4244|C4701|C4057|C4245|C4706|C4232)"
  # C4131: uses old-style declarator
  # C4244: conversion from '...' to '...', possible loss of data
  # C4127: conditional expression is constant
  "y.tab.c.*warning (C4131|C4244|C4127|C4701)"
  # C4100: unreferenced formal parameter
  "getdate.y.*warning(C4100|C4127|C4244)"
  # Mac
  "curl.mprintf.*warning.*redefined"
  "usr.include.secure._stdio.h.*warning: this is the location of the previous definition"
  "ranlib: file:.*bin.libslicerlibcurl.a.*has no symbols"

  #PythonQt
  "PythonQt.src"
  "PythonQt.PythonQtConversion.h.*deprecated-writable-strings"
  "PythonQt.src.PythonQtConversion.(cpp|h).*write-strings"
  "PythonQt.src.PythonQtConversion.cpp.*tautological-compare"
  "PythonQt.src.PythonQtSlot.cpp.*unused-value"
  "PythonQt.src.PythonQtSignalReceiver.cpp.*logical-op-parentheses"
  "PythonQt.PythonQtInstanceWrapper.h.*old-style-cast"
  "[Pp]ython[Qq]t.generated_cpp"
  "pythonqt-build.generated_cpp"
  "QStyleOption.*V(2|3|4).*deprecated"
  "([0-9]+) warnings generated."
  "(QNetworkProxyQuery|networkConfiguration|setNetworkConfiguration).*deprecated"

  #Libarchive
  "LibArchive.libArchive.*signed/unsigned mismatch"
  "LibArchive.libArchive.*conversion from 'size_t' to '.*', possible loss of data"

  # Visual studio spurious warnings...
  "The following environment variables were not found"

  # Since NUMPY has test that return build errors, let's add the following exception
  "WARNING non-zero return value in ctest from"

  # Git
  "HEAD is now"

  # SimpleITK: Warning from SWIG with self member type
  "sitkCommand.* [wW]arning 314.*self.*is a python keyword"
  )

set(CTEST_CUSTOM_ERROR_EXCEPTION
  ${CTEST_CUSTOM_ERROR_EXCEPTION}
  # Python - Windows
  # These warnings are interpreted as errors on Windows
  "UserWarning:"
  # Numpy errors
  "NUMPY.*Warning"
  "NUMPY._configtest.*undefined reference"
  "_configtest.*error"
  "collect2: ld returned 1 exit status"
  )
