mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
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!)
This commit is contained in:
parent
071b585b6b
commit
329bcc46c5
@ -424,7 +424,6 @@ bool QgsRenderChecker::compareImages( const QString &testName, const QString &re
|
||||
//
|
||||
// Set the report with the result
|
||||
//
|
||||
mReport = QStringLiteral( "<script src=\"file://%1/../renderchecker.js\"></script>\n" ).arg( TEST_DATA_DIR );
|
||||
mReport += QLatin1String( "<table>" );
|
||||
mReport += QLatin1String( "<tr><td colspan=2>" );
|
||||
mReport += QStringLiteral( "<tr><td colspan=2>"
|
||||
|
@ -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( "<h1>Test results</h1>\n" );
|
||||
|
||||
// embed render checker script so that we can run the HTML report from anywhere
|
||||
stream << QStringLiteral( "<script>" );
|
||||
QFile renderCheckerScript( QStringLiteral( TEST_DATA_DIR ) + "/../renderchecker.js" );
|
||||
if ( renderCheckerScript.open( QIODevice::ReadOnly ) )
|
||||
{
|
||||
stream << renderCheckerScript.readAll();
|
||||
}
|
||||
stream << QStringLiteral( "</script>" );
|
||||
}
|
||||
|
||||
stream << QStringLiteral( "<h1>%1</h1>\n" ).arg( mName );
|
||||
stream << report;
|
||||
file.close();
|
||||
|
Loading…
x
Reference in New Issue
Block a user