Slightly speed up grass provider tests

These tests involve re-opening a LOT of grass layers, which
in turn requires calls to qgis.g.info to retrieve the layer CRS.

On newer GRASS versions this has slowed down significantly. While
it shouldn't impact actual QGIS users (they won't be reopening as
many datasets in such a short period of time as the test is doing),
it is causing test timeouts and fragility.

Workaround this by re-working all tests to use the newer PROJ_SRID
metadata approach, so that we get CRS information on the first
call to qgis.g.info and don't need to fallback to subsequent calls
to retrieve the CRS using the older, lossy metadata keys. This
drops test execution time from ~45 seconds to ~30 seconds on
my machine. (The downside is less/no test coverage for the older
CRS metadata key handling)
This commit is contained in:
Nyall Dawson 2025-09-11 09:36:19 +10:00
parent a1e8f25fa2
commit 64b0491260

View File

@ -596,8 +596,7 @@ void TestQgsGrassProvider::info()
}
reportRow( QLatin1String( "" ) );
QgsCoordinateReferenceSystem expectedCrs;
expectedCrs.createFromString( QStringLiteral( "WKT:GEOGCS[\"wgs84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS_1984\",6378137,298.257223563],TOWGS84[0,0,0,0,0,0,0]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9122\"]]]" ) );
QgsCoordinateReferenceSystem expectedCrs( QStringLiteral( "EPSG:4326" ) );
reportRow( "expectedCrs: " + expectedCrs.toWkt() );
QString error;
@ -763,7 +762,7 @@ bool TestQgsGrassProvider::createTmpLocation( QString &tmpGisdbase, QString &tmp
}
QStringList cpFiles;
cpFiles << QStringLiteral( "DEFAULT_WIND" ) << QStringLiteral( "WIND" ) << QStringLiteral( "PROJ_INFO" ) << QStringLiteral( "PROJ_UNITS" );
cpFiles << QStringLiteral( "DEFAULT_WIND" ) << QStringLiteral( "WIND" ) << QStringLiteral( "PROJ_INFO" ) << QStringLiteral( "PROJ_UNITS" ) << QStringLiteral( "PROJ_SRID" );
QString templateMapsetPath = mGisdbase + "/" + mLocation + "/PERMANENT";
Q_FOREACH ( const QString &cpFile, cpFiles )
{