mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-05 00:09:32 -04:00
QgsMultiRenderChecker: avoid misleading console output noise
When the checker passes comparison against ANY reference image, don't output mismatch failure message for all the other variants
This commit is contained in:
parent
09a4e5449e
commit
712b3e72c6
@ -1,11 +1,16 @@
|
||||
# The following has been generated automatically from src/core/qgsrenderchecker.h
|
||||
# monkey patching scoped based enum
|
||||
QgsRenderChecker.Flag.AvoidExportingRenderedImage.__doc__ = "Avoids exporting rendered images to reports"
|
||||
QgsRenderChecker.Flag.Silent.__doc__ = "Don't output non-critical messages to console \n.. versionadded:: 3.40"
|
||||
QgsRenderChecker.Flag.__doc__ = """Render checker flags.
|
||||
|
||||
.. versionadded:: 3.28
|
||||
|
||||
* ``AvoidExportingRenderedImage``: Avoids exporting rendered images to reports
|
||||
* ``Silent``: Don't output non-critical messages to console
|
||||
|
||||
.. versionadded:: 3.40
|
||||
|
||||
|
||||
"""
|
||||
# --
|
||||
|
@ -183,6 +183,7 @@ Sets the largest allowable difference in size between the rendered and the expec
|
||||
enum class Flag /BaseType=IntFlag/
|
||||
{
|
||||
AvoidExportingRenderedImage,
|
||||
Silent,
|
||||
};
|
||||
|
||||
typedef QFlags<QgsRenderChecker::Flag> Flags;
|
||||
|
@ -1,11 +1,16 @@
|
||||
# The following has been generated automatically from src/core/qgsrenderchecker.h
|
||||
# monkey patching scoped based enum
|
||||
QgsRenderChecker.Flag.AvoidExportingRenderedImage.__doc__ = "Avoids exporting rendered images to reports"
|
||||
QgsRenderChecker.Flag.Silent.__doc__ = "Don't output non-critical messages to console \n.. versionadded:: 3.40"
|
||||
QgsRenderChecker.Flag.__doc__ = """Render checker flags.
|
||||
|
||||
.. versionadded:: 3.28
|
||||
|
||||
* ``AvoidExportingRenderedImage``: Avoids exporting rendered images to reports
|
||||
* ``Silent``: Don't output non-critical messages to console
|
||||
|
||||
.. versionadded:: 3.40
|
||||
|
||||
|
||||
"""
|
||||
# --
|
||||
|
@ -183,6 +183,7 @@ Sets the largest allowable difference in size between the rendered and the expec
|
||||
enum class Flag
|
||||
{
|
||||
AvoidExportingRenderedImage,
|
||||
Silent,
|
||||
};
|
||||
|
||||
typedef QFlags<QgsRenderChecker::Flag> Flags;
|
||||
|
@ -78,13 +78,11 @@ bool QgsMultiRenderChecker::runTest( const QString &testName, unsigned int misma
|
||||
// we can only report one diff image, so just use the first
|
||||
QString diffImageFile;
|
||||
|
||||
QMap< QString, int > variantMismatchCount;
|
||||
QMap< QString, int > variantSize;
|
||||
|
||||
for ( const QString &suffix : std::as_const( subDirs ) )
|
||||
{
|
||||
if ( subDirs.count() > 1 )
|
||||
{
|
||||
qDebug() << "Checking subdir " << suffix;
|
||||
}
|
||||
bool result;
|
||||
QgsRenderChecker checker;
|
||||
checker.enableDashBuffering( true );
|
||||
checker.setColorTolerance( mColorTolerance );
|
||||
@ -95,14 +93,15 @@ bool QgsMultiRenderChecker::runTest( const QString &testName, unsigned int misma
|
||||
checker.setMapSettings( mMapSettings );
|
||||
checker.setExpectFail( mExpectFail );
|
||||
|
||||
bool result = false;
|
||||
if ( !mRenderedImage.isNull() )
|
||||
{
|
||||
checker.setRenderedImage( mRenderedImage );
|
||||
result = checker.compareImages( testName, mismatchCount, mRenderedImage, QgsRenderChecker::Flag::AvoidExportingRenderedImage );
|
||||
result = checker.compareImages( testName, mismatchCount, mRenderedImage, QgsRenderChecker::Flag::AvoidExportingRenderedImage | QgsRenderChecker::Flag::Silent );
|
||||
}
|
||||
else
|
||||
{
|
||||
result = checker.runTest( testName, mismatchCount, QgsRenderChecker::Flag::AvoidExportingRenderedImage );
|
||||
result = checker.runTest( testName, mismatchCount, QgsRenderChecker::Flag::AvoidExportingRenderedImage | QgsRenderChecker::Flag::Silent );
|
||||
mRenderedImage = checker.renderedImage();
|
||||
}
|
||||
|
||||
@ -120,6 +119,11 @@ bool QgsMultiRenderChecker::runTest( const QString &testName, unsigned int misma
|
||||
{
|
||||
diffImageFile = checker.mDiffImageFile;
|
||||
}
|
||||
if ( !mResult )
|
||||
{
|
||||
variantMismatchCount.insert( suffix, checker.mismatchCount() );
|
||||
variantSize.insert( suffix, checker.matchTarget() );
|
||||
}
|
||||
}
|
||||
|
||||
if ( !mResult && !mExpectFail && mIsCiRun )
|
||||
@ -148,6 +152,17 @@ bool QgsMultiRenderChecker::runTest( const QString &testName, unsigned int misma
|
||||
|
||||
if ( !mResult && !mExpectFail )
|
||||
{
|
||||
for ( auto it = variantMismatchCount.constBegin(); it != variantMismatchCount.constEnd(); it++ )
|
||||
{
|
||||
if ( subDirs.size() > 1 )
|
||||
{
|
||||
qDebug() << QStringLiteral( "Variant %1: %2/%3 pixels mismatched (%4 allowed)" ).arg( it.key() ).arg( it.value() ).arg( variantSize.value( it.key() ) ).arg( mismatchCount );
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << QStringLiteral( "%1/%2 pixels mismatched (%4 allowed)" ).arg( it.value() ).arg( variantSize.value( it.key() ) ).arg( mismatchCount );
|
||||
}
|
||||
}
|
||||
const QDir reportDir = QgsRenderChecker::testReportDir();
|
||||
if ( !reportDir.exists() )
|
||||
{
|
||||
|
@ -523,7 +523,9 @@ bool QgsRenderChecker::compareImages( const QString &testName, const QString &re
|
||||
// Put the same info to debug too
|
||||
//
|
||||
|
||||
if ( expectedImage.width() != myResultImage.width() || expectedImage.height() != myResultImage.height() )
|
||||
if ( !flags.testFlag( Flag::Silent )
|
||||
&& ( expectedImage.width() != myResultImage.width() || expectedImage.height() != myResultImage.height() )
|
||||
)
|
||||
{
|
||||
qDebug( "Expected size: %dw x %dh", expectedImage.width(), expectedImage.height() );
|
||||
qDebug( "Actual size: %dw x %dh", myResultImage.width(), myResultImage.height() );
|
||||
@ -533,7 +535,10 @@ bool QgsRenderChecker::compareImages( const QString &testName, const QString &re
|
||||
|
||||
if ( mMatchTarget != myPixelCount )
|
||||
{
|
||||
qDebug( "Expected image and rendered image for %s are different dimensions", testName.toLocal8Bit().constData() );
|
||||
if ( !flags.testFlag( Flag::Silent ) )
|
||||
{
|
||||
qDebug( "Expected image and rendered image for %s are different dimensions", testName.toLocal8Bit().constData() );
|
||||
}
|
||||
|
||||
if ( std::abs( expectedImage.width() - myResultImage.width() ) > mMaxSizeDifferenceX ||
|
||||
std::abs( expectedImage.height() - myResultImage.height() ) > mMaxSizeDifferenceY )
|
||||
@ -690,7 +695,10 @@ bool QgsRenderChecker::compareImages( const QString &testName, const QString &re
|
||||
emitDashMessage( "Rendered Image " + testName + prefix, QgsDartMeasurement::ImagePng, mRenderedImageFile );
|
||||
emitDashMessage( "Expected Image " + testName + prefix, QgsDartMeasurement::ImagePng, referenceImageFile );
|
||||
|
||||
qDebug( "%d/%d pixels mismatched (%d allowed)", mMismatchCount, mMatchTarget, mismatchCount );
|
||||
if ( !flags.testFlag( Flag::Silent ) )
|
||||
{
|
||||
qDebug( "%d/%d pixels mismatched (%d allowed)", mMismatchCount, mMatchTarget, mismatchCount );
|
||||
}
|
||||
|
||||
//
|
||||
//save the diff image to disk
|
||||
|
@ -199,6 +199,7 @@ class CORE_EXPORT QgsRenderChecker
|
||||
enum class Flag : int SIP_ENUM_BASETYPE( IntFlag )
|
||||
{
|
||||
AvoidExportingRenderedImage = 1 << 0, //!< Avoids exporting rendered images to reports
|
||||
Silent = 1 << 1, //!< Don't output non-critical messages to console \since QGIS 3.40
|
||||
};
|
||||
Q_ENUM( Flag )
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user