From 329bcc46c59a047ee5f7dd4f0405a734e24fbfd9 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Tue, 10 Oct 2023 08:17:50 +1000 Subject: [PATCH] Embed render checker script in report html instead of linking to QGIS source code file Makes the HTML report a bit more self-contained, and unbreaks this script when viewing report artifacts from github (image paths are still broken, though!) --- src/core/qgsrenderchecker.cpp | 1 - src/test/qgstest.h | 24 ++++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/core/qgsrenderchecker.cpp b/src/core/qgsrenderchecker.cpp index 2d3b1f1603a..2f31156bf1b 100644 --- a/src/core/qgsrenderchecker.cpp +++ b/src/core/qgsrenderchecker.cpp @@ -424,7 +424,6 @@ bool QgsRenderChecker::compareImages( const QString &testName, const QString &re // // Set the report with the result // - mReport = QStringLiteral( "\n" ).arg( TEST_DATA_DIR ); mReport += QLatin1String( "" ); mReport += QLatin1String( "
" ); mReport += QStringLiteral( "
" diff --git a/src/test/qgstest.h b/src/test/qgstest.h index 5f678361392..3aa0d8af627 100644 --- a/src/test/qgstest.h +++ b/src/test/qgstest.h @@ -345,15 +345,39 @@ class TEST_EXPORT QgsTest : public QObject QFile file( reportFile ); QFile::OpenMode mode = QIODevice::WriteOnly; + bool fileIsEmpty = true; if ( qgetenv( "QGIS_CONTINUOUS_INTEGRATION_RUN" ) == QStringLiteral( "true" ) || qgetenv( "QGIS_APPEND_TO_TEST_REPORT" ) == QStringLiteral( "true" ) ) + { mode |= QIODevice::Append; + if ( file.open( QIODevice::ReadOnly ) ) + { + fileIsEmpty = file.readAll().isEmpty(); + } + } else + { mode |= QIODevice::Truncate; + } if ( file.open( mode ) ) { QTextStream stream( &file ); + if ( fileIsEmpty ) + { + // append standard header + stream << QStringLiteral( "

Test results

\n" ); + + // embed render checker script so that we can run the HTML report from anywhere + stream << QStringLiteral( "" ); + } + stream << QStringLiteral( "

%1

\n" ).arg( mName ); stream << report; file.close();