fix grass tests on windows

This commit is contained in:
Juergen E. Fischer 2015-07-07 23:24:18 +02:00
parent 92af85b7a2
commit fa464111c8
32 changed files with 149 additions and 103 deletions

View File

@ -390,6 +390,7 @@ IF (PEDANTIC)
# disable warnings
SET(_warnings "${_warnings} /wd4100 ") # unused formal parameters
SET(_warnings "${_warnings} /wd4127 ") # constant conditional expressions (used in Qt template classes)
SET(_warnings "${_warnings} /wd4190 ") # 'identifier' has C-linkage specified, but returns UDT 'identifier2' which is incompatible with C
SET(_warnings "${_warnings} /wd4231 ") # nonstandard extension used : 'identifier' before template explicit instantiation (used in Qt template classes)
SET(_warnings "${_warnings} /wd4244 ") # conversion from '...' to '...' possible loss of data
SET(_warnings "${_warnings} /wd4251 ") # needs to have dll-interface to be used by clients of class (occurs in Qt template classes)

View File

@ -127,7 +127,7 @@ QString QgsOpenVectorLayerDialog::openDirectory()
//process path if it is grass
if ( cmbDirectoryTypes->currentText() == "Grass Vector" )
{
#ifdef WIN32
#ifdef Q_OS_WIN
//replace backslashes with forward slashes
path.replace( "\\", "/" );
#endif

View File

@ -47,10 +47,10 @@
// Do we need this?
// #define TESTLIB
#ifdef TESTLIB
// This doesn't work on WIN32 and causes problems with plugins
// This doesn't work on windows and causes problems with plugins
// on OS X (the code doesn't cause a problem but including dlfcn.h
// renders plugins unloadable)
#if !defined(WIN32) && !defined(Q_OS_MACX)
#if !defined(Q_OS_WIN) && !defined(Q_OS_MACX)
#include <dlfcn.h>
#endif
#endif
@ -291,7 +291,7 @@ void QgsPluginManager::savePluginState( QString id, bool state )
void QgsPluginManager::getCppPluginsMetadata()
{
QString sharedLibExtension;
#if defined(WIN32) || defined(__CYGWIN__)
#if defined(Q_OS_WIN) || defined(__CYGWIN__)
sharedLibExtension = "*.dll";
#else
sharedLibExtension = "*.so*";
@ -325,12 +325,12 @@ void QgsPluginManager::getCppPluginsMetadata()
QString lib = QString( "%1/%2" ).arg( myPluginDir ).arg( pluginDir[i] );
#ifdef TESTLIB
// This doesn't work on WIN32 and causes problems with plugins
// This doesn't work on windows and causes problems with plugins
// on OS X (the code doesn't cause a problem but including dlfcn.h
// renders plugins unloadable)
#if !defined(WIN32) && !defined(Q_OS_MACX)
#if !defined(Q_OS_WIN) && !defined(Q_OS_MACX)
// test code to help debug loading problems
// This doesn't work on WIN32 and causes problems with plugins
// This doesn't work on windows and causes problems with plugins
// on OS X (the code doesn't cause a problem but including dlfcn.h
// renders plugins unloadable)
@ -346,7 +346,7 @@ void QgsPluginManager::getCppPluginsMetadata()
QgsDebugMsg( "dlopen suceeded for " + lib );
dlclose( handle );
}
#endif //#ifndef WIN32 && Q_OS_MACX
#endif //#ifndef Q_OS_WIN && Q_OS_MACX
#endif //#ifdef TESTLIB
QgsDebugMsg( "Examining: " + lib );

View File

@ -219,7 +219,7 @@ void QgisAppStyleSheet::setActiveValues()
#else
mLinuxOS = false;
#endif
#ifdef Q_OS_WIN32
#ifdef Q_OS_WIN
mWinOS = true;
#else
mWinOS = false;

View File

@ -351,7 +351,7 @@ void QgsPluginRegistry::loadCppPlugin( QString theFullPathName )
QgsDebugMsg( QString( "plugin object name: %1" ).arg( o->objectName() ) );
if ( o->objectName().isEmpty() )
{
#ifndef WIN32
#ifndef Q_OS_WIN
baseName = baseName.mid( 3 );
#endif
QgsDebugMsg( QString( "object name to %1" ).arg( baseName ) );
@ -449,7 +449,7 @@ void QgsPluginRegistry::restoreSessionPlugins( QString thePluginDirString )
{
QSettings mySettings;
#if defined(WIN32) || defined(__CYGWIN__)
#if defined(Q_OS_WIN) || defined(__CYGWIN__)
QString pluginExt = "*.dll";
#elif ANDROID
QString pluginExt = "*plugin.so";

View File

@ -76,7 +76,7 @@ void QgsTicksScaleBarStyle::draw( QPainter* p, double xOffset ) const
if ( !segmentInfo.isEmpty() )
{
double lastTickPositionX = segmentInfo.last().first + mScaleBar->segmentMillimeters() + xOffset;
double verticalPos;
double verticalPos = 0.0;
switch ( mTickPosition )
{
case TicksDown:

View File

@ -203,21 +203,21 @@ class CORE_EXPORT QGis
*/
enum DataType
{
/*! Unknown or unspecified type */ UnknownDataType = 0,
/*! Eight bit unsigned integer (quint8) */ Byte = 1,
/*! Sixteen bit unsigned integer (quint16) */ UInt16 = 2,
/*! Sixteen bit signed integer (qint16) */ Int16 = 3,
/*! Thirty two bit unsigned integer (quint32) */ UInt32 = 4,
/*! Thirty two bit signed integer (qint32) */ Int32 = 5,
/*! Thirty two bit floating point (float) */ Float32 = 6,
/*! Sixty four bit floating point (double) */ Float64 = 7,
/*! Complex Int16 */ CInt16 = 8,
/*! Complex Int32 */ CInt32 = 9,
/*! Complex Float32 */ CFloat32 = 10,
/*! Complex Float64 */ CFloat64 = 11,
/*! Color, alpha, red, green, blue, 4 bytes the same as
/** Unknown or unspecified type */ UnknownDataType = 0,
/** Eight bit unsigned integer (quint8) */ Byte = 1,
/** Sixteen bit unsigned integer (quint16) */ UInt16 = 2,
/** Sixteen bit signed integer (qint16) */ Int16 = 3,
/** Thirty two bit unsigned integer (quint32) */ UInt32 = 4,
/** Thirty two bit signed integer (qint32) */ Int32 = 5,
/** Thirty two bit floating point (float) */ Float32 = 6,
/** Sixty four bit floating point (double) */ Float64 = 7,
/** Complex Int16 */ CInt16 = 8,
/** Complex Int32 */ CInt32 = 9,
/** Complex Float32 */ CFloat32 = 10,
/** Complex Float64 */ CFloat64 = 11,
/** Color, alpha, red, green, blue, 4 bytes the same as
QImage::Format_ARGB32 */ ARGB32 = 12,
/*! Color, alpha, red, green, blue, 4 bytes the same as
/** Color, alpha, red, green, blue, 4 bytes the same as
QImage::Format_ARGB32_Premultiplied */ ARGB32_Premultiplied = 13
};
@ -435,12 +435,12 @@ const double MINIMUM_POINT_SIZE = 0.1;
const double DEFAULT_POINT_SIZE = 2.0;
const double DEFAULT_LINE_WIDTH = 0.26;
/** default snapping tolerance for segments */
/** Default snapping tolerance for segments */
const double DEFAULT_SEGMENT_EPSILON = 1e-8;
typedef QMap<QString, QString> QgsStringMap;
/** qgssize is used instead of size_t, because size_t is stdlib type, unknown
/** Qgssize is used instead of size_t, because size_t is stdlib type, unknown
* by SIP, and it would be hard to define size_t correctly in SIP.
* Currently used "unsigned long long" was introduced in C++11 (2011)
* but it was supported already before C++11 on common platforms.
@ -466,7 +466,7 @@ typedef unsigned long long qgssize;
#endif
#ifndef QGISEXTERN
#ifdef WIN32
#ifdef Q_OS_WIN
# define QGISEXTERN extern "C" __declspec( dllexport )
# ifdef _MSC_VER
// do not warn about C bindings returing QString

View File

@ -154,7 +154,7 @@ void QgsApplication::init( QString customConfigPath )
char *prefixPath = getenv( "QGIS_PREFIX_PATH" );
if ( !prefixPath )
{
#if defined(Q_OS_MACX) || defined(Q_OS_WIN32) || defined(WIN32)
#if defined(Q_OS_MACX) || defined(Q_OS_WIN)
setPrefixPath( applicationDirPath(), true );
#elif defined(ANDROID)
// this is "/data/data/org.qgis.qgis" in android
@ -924,7 +924,7 @@ bool QgsApplication::createDB( QString *errorMessage )
myDir.mkpath( myPamPath ); //fail silently
}
#if defined(Q_OS_WIN32) || defined(WIN32)
#if defined(Q_OS_WIN)
CPLSetConfigOption( "GDAL_PAM_PROXY_DIR", myPamPath.toUtf8() );
#else
//under other OS's we use an environment var so the user can

View File

@ -783,7 +783,7 @@ bool QgsCoordinateTransform::writeXML( QDomNode & theNode, QDomDocument & theDoc
const char *finder( const char *name )
{
QString proj;
#ifdef WIN32
#ifdef Q_OS_WIN
proj = QApplication::applicationDirPath()
+ "/share/proj/" + QString( name );
#else

View File

@ -731,7 +731,9 @@ QgsDataCollectionItem::~QgsDataCollectionItem()
//-----------------------------------------------------------------------
// QVector<QgsDataProvider*> QgsDirectoryItem::mProviders = QVector<QgsDataProvider*>();
Q_NOWARN_DEPRECATED_PUSH
QVector<QLibrary*> QgsDirectoryItem::mLibraries = QVector<QLibrary*>();
Q_NOWARN_DEPRECATED_POP
QgsDirectoryItem::QgsDirectoryItem( QgsDataItem* parent, QString name, QString path )
: QgsDataCollectionItem( parent, name, path )

View File

@ -39,7 +39,7 @@
#include "qgslabel.h"
// use M_PI define PI 3.141592654
#ifdef WIN32
#ifdef Q_OS_WIN
#undef M_PI
#define M_PI 4*atan(1.0)
#endif

View File

@ -72,7 +72,7 @@ QgsProviderRegistry::QgsProviderRegistry( QString pluginPath )
mLibraryDirectory.setSorting( QDir::Name | QDir::IgnoreCase );
mLibraryDirectory.setFilter( QDir::Files | QDir::NoSymLinks );
#if defined(WIN32) || defined(__CYGWIN__)
#if defined(Q_OS_WIN) || defined(__CYGWIN__)
mLibraryDirectory.setNameFilters( QStringList( "*.dll" ) );
#elif ANDROID
mLibraryDirectory.setNameFilters( QStringList( "*provider.so" ) );
@ -242,7 +242,7 @@ QgsProviderRegistry::~QgsProviderRegistry()
}
/** convenience function for finding any existing data providers that match "providerKey"
/** Convenience function for finding any existing data providers that match "providerKey"
Necessary because [] map operator will create a QgsProviderMetadata
instance. Also you cannot use the map [] operator in const members for that

View File

@ -46,7 +46,7 @@
#include "qwt5_histogram_item.h"
#endif
#ifdef WIN32
#ifdef Q_OS_WIN
#include <time.h>
#endif

View File

@ -75,7 +75,7 @@ void QgsHelpViewer::showHelp( QString help )
webView->setHtml( helpContents );
setWindowTitle( tr( "QGIS Help" ) );
#ifndef WIN32
#ifndef Q_OS_WIN
setWindowState( windowState() & ~Qt::WindowMinimized );
#endif
raise();

View File

@ -65,7 +65,7 @@ eVisDatabaseConnectionGui::eVisDatabaseConnectionGui( QList<QTemporaryFile*>* th
connect( mDatabaseLayerFieldSelector, SIGNAL( eVisDatabaseLayerFieldsSelected( QString, QString, QString ) ), this, SLOT( drawNewVectorLayer( QString, QString, QString ) ) );
//Populate gui components
#ifdef WIN32
#ifdef Q_OS_WIN
cboxDatabaseType->insertItem( 0, "MSAccess" );
#endif
cboxDatabaseType->insertItem( 0, "MYSQL" );

View File

@ -788,14 +788,14 @@ void GlobePlugin::setupProxy()
if ( !settings.value( "/proxyUser" ).toString().isEmpty() )
{
QString auth = settings.value( "/proxyUser" ).toString() + ":" + settings.value( "/proxyPassword" ).toString();
#ifdef WIN32
#ifdef Q_OS_WIN
putenv( QString( "OSGEARTH_CURL_PROXYAUTH=%1" ).arg( auth ).toAscii() );
#else
setenv( "OSGEARTH_CURL_PROXYAUTH", auth.toStdString().c_str(), 0 );
#endif
}
//TODO: settings.value("/proxyType")
//TODO: URL exlusions
//TODO: URL exclusions
HTTPClient::setProxySettings( proxySettings );
}
settings.endGroup();

View File

@ -72,7 +72,7 @@ QString QgsGrassModule::findExec( QString file )
QString path = getenv( "PATH" );
QgsDebugMsg( "path = " + path );
#ifdef WIN32
#ifdef Q_OS_WIN
mExecPath = path.split( ";" );
mExecPath.prepend( QgsGrass::shortPath( QgsApplication::applicationDirPath() ) );
#else
@ -85,7 +85,7 @@ QString QgsGrassModule::findExec( QString file )
if ( QFile::exists( file ) )
return file; // full path
#ifdef WIN32
#ifdef Q_OS_WIN
// On windows try .bat first
for ( QStringList::iterator it = mExecPath.begin();
it != mExecPath.end(); ++it )
@ -141,7 +141,7 @@ QStringList QgsGrassModule::execArguments( QString module )
return arguments;
}
#if defined(WIN32)
#ifdef Q_OS_WIN
if ( exe.endsWith( ".py" ) )
{
arguments.append( "python" );
@ -213,7 +213,7 @@ QgsGrassModule::QgsGrassModule( QgsGrassTools *tools, QString moduleName, QgisIn
// but not all modules have to be binary (can be scripts)
// => test if the module is in path and if it is not
// add .exe and test again
#ifdef WIN32
#ifdef Q_OS_WIN
if ( inExecPath( xName ) )
{
mXName = xName;
@ -749,7 +749,7 @@ void QgsGrassModuleStandardOptions::freezeOutput()
{
QgsDebugMsg( "called." );
#ifdef WIN32
#ifdef Q_OS_WIN
for ( unsigned int i = 0; i < mItems.size(); i++ )
{
QgsGrassModuleOption *opt = dynamic_cast<QgsGrassModuleOption *>( mItems[i] );
@ -824,7 +824,7 @@ void QgsGrassModuleStandardOptions::thawOutput()
{
QgsDebugMsg( "called." );
#ifdef WIN32
#ifdef Q_OS_WIN
for ( unsigned int i = 0; i < mItems.size(); i++ )
{
QgsGrassModuleOption *opt = dynamic_cast<QgsGrassModuleOption *>( mItems[i] );
@ -1695,7 +1695,7 @@ void QgsGrassModule::run()
return;
}
#if defined(WIN32)
#ifdef Q_OS_WIN
// we already know it exists from execArguments()
QString exe = QgsGrassModule::findExec( mXName );
QFileInfo fi( exe );

View File

@ -1268,7 +1268,7 @@ void QgsGrassNewMapset::createMapset()
// database path
( void )QgsGrass::activeMode(); // because it calls private QgsGrass::init()
#if defined(WIN32)
#ifdef Q_OS_WIN
G__setenv(( char * ) "GISDBASE", QgsGrass::shortPath( mDatabaseLineEdit->text() ).toUtf8().data() );
#else
G__setenv(( char * ) "GISDBASE", mDatabaseLineEdit->text().toUtf8().data() );

View File

@ -173,7 +173,7 @@ void QgsGrassElementDialog::textChanged()
return;
}
#ifdef WIN32
#ifdef Q_OS_WIN
if ( !mSource.isNull() && text.toLower() == mSource.toLower() )
#else
if ( !mSource.isNull() && text == mSource )

View File

@ -201,7 +201,7 @@ static int cell_draw( char *name,
set = G_malloc( ncols );
/* some buggy C libraries require BOTH setmode() and fdopen(bin) */
#ifdef WIN32
#ifdef Q_OS_WIN
if ( _setmode( _fileno( stdout ), _O_BINARY ) == -1 )
G_fatal_error( "Cannot set stdout mode" );
#endif

View File

@ -19,7 +19,6 @@ extern "C"
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <assert.h>
#ifdef WIN32
#include <fcntl.h>
#include <io.h>
@ -93,7 +92,7 @@ int main( int argc, char **argv )
name = map->answer;
#ifdef Q_OS_WIN32
#ifdef Q_OS_WIN
_setmode( _fileno( stdin ), _O_BINARY );
_setmode( _fileno( stdout ), _O_BINARY );
//setvbuf( stdin, NULL, _IONBF, BUFSIZ );
@ -176,9 +175,9 @@ int main( int argc, char **argv )
return 1;
}
qint32 *cell;
float *fcell;
double *dcell;
qint32 *cell = 0;
float *fcell = 0;
double *dcell = 0;
if ( grass_type == CELL_TYPE )
cell = ( qint32* ) byteArray.data();
else if ( grass_type == FCELL_TYPE )

View File

@ -134,7 +134,7 @@ int main( int argc, char **argv )
if ( G_parser( argc, argv ) )
exit( EXIT_FAILURE );
#ifdef Q_OS_WIN32
#ifdef Q_OS_WIN
_setmode( _fileno( stdin ), _O_BINARY );
_setmode( _fileno( stdout ), _O_BINARY );
#endif

View File

@ -333,7 +333,11 @@ void GRASS_LIB_EXPORT QgsGrass::init( void )
#ifdef Q_OS_WIN
// Use the applicationDirPath()/grass
gisBase = shortPath( QCoreApplication::applicationDirPath() + "/grass" );
#ifdef _MSC_VER
gisBase = shortPath( QCoreApplication::applicationDirPath() + ( QgsApplication::isRunningFromBuildDir() ? + "/../.." : "" ) + "/grass" );
#else
gisBase = shortPath( QCoreApplication::applicationDirPath() + ( QgsApplication::isRunningFromBuildDir() ? + "/.." : "" ) + "/grass" );
#endif
QgsDebugMsg( QString( "GRASS gisBase = %1" ).arg( gisBase ) );
#elif defined(Q_OS_MACX)
// check for bundled GRASS, fall back to configured path
@ -380,7 +384,7 @@ void GRASS_LIB_EXPORT QgsGrass::init( void )
userGisbase = false;
break;
}
#ifdef Q_OS_WIN32
#ifdef Q_OS_WIN
gisBase = shortPath( gisBase );
#endif
}
@ -1692,7 +1696,7 @@ QString GRASS_LIB_EXPORT QgsGrass::getInfo( const QString& info, const QString&
QStringList arguments;
QString cmd = QgsApplication::libexecPath() + "grass/modules/qgis.g.info";
QString cmd = qgisGrassModulePath() + "/qgis.g.info";
arguments.append( "info=" + info );
if ( !map.isEmpty() )
@ -2200,7 +2204,7 @@ QString GRASS_LIB_EXPORT QgsGrass::versionString()
Qt::CaseSensitivity GRASS_LIB_EXPORT QgsGrass::caseSensitivity()
{
#ifdef WIN32
#ifdef Q_OS_WIN
return Qt::CaseInsensitive;
#else
return Qt::CaseSensitive;
@ -2250,7 +2254,7 @@ struct Map_info GRASS_LIB_EXPORT *QgsGrass::vectNewMapStruct()
// may have different sizes of types, see issue #13002. Because there is no Vect_new_map_struct (GRASS 7.0.0, July 2015)
// the structure is allocated here using doubled (should be enough) space.
// TODO: replace by Vect_new_map_struct once it appears in GRASS
#if defined(WIN32)
#ifdef Q_OS_WIN
return ( struct Map_info* ) qgsMalloc( 2*sizeof( struct Map_info ) );
#else
return ( struct Map_info* ) qgsMalloc( sizeof( struct Map_info ) );

View File

@ -147,7 +147,7 @@ class QgsGrass
};
//! Get info about the mode
/*! QgsGrass may be running in active or passive mode.
/** QgsGrass may be running in active or passive mode.
* Active mode means that GISRC is set up and GISRC file is available,
* in that case default GISDBASE, LOCATION and MAPSET may be read by GetDefaul*() functions.
* Passive mode means, that GISRC is not available. */
@ -409,12 +409,21 @@ class QgsGrass
// set environment variable
static GRASS_LIB_EXPORT void putEnv( QString name, QString value );
#if defined(WIN32)
#ifdef Q_OS_WIN
static GRASS_LIB_EXPORT QString shortPath( const QString &path );
#endif
// path to QGIS GRASS modules like qgis.g.info etc.
static GRASS_LIB_EXPORT QString qgisGrassModulePath() { return QgsApplication::libexecPath() + "grass/modules"; }
static GRASS_LIB_EXPORT QString qgisGrassModulePath()
{
#ifdef _MSC_VER
if ( QgsApplication::isRunningFromBuildDir() )
{
return QCoreApplication::applicationDirPath() + "/../../grass/modules/" + QgsApplication::cfgIntDir();
}
#endif
return QgsApplication::libexecPath() + "grass/modules";
}
// Allocate struct Map_info
static GRASS_LIB_EXPORT struct Map_info * vectNewMapStruct();

View File

@ -245,7 +245,7 @@ QSqlDatabase QgsMssqlProvider::GetDatabase( QString service, QString host, QStri
}
else
{
#ifdef WIN32
#ifdef Q_OS_WIN
connectionString = "driver={SQL Server}";
#else
connectionString = "driver={FreeTDS};port=1433";

View File

@ -1686,7 +1686,7 @@ QString createFilters( QString type )
else if ( driverName.startsWith( "PGeo" ) )
{
myDatabaseDrivers += QObject::tr( "ESRI Personal GeoDatabase" ) + ",PGeo;";
#ifdef WIN32
#ifdef Q_OS_WIN
myFileFilters += createFileFilter_( QObject::tr( "ESRI Personal GeoDatabase" ), "*.mdb" );
myExtensions << "mdb";
#endif

View File

@ -38,7 +38,7 @@ QString QgsMSUtils::createTempFilePath()
QString tempFilePath;
//on windows, store the temporary file in current_path/tmp directory,
//on unix, store it in /tmp/qgis_wms_serv
#ifndef WIN32
#ifndef Q_OS_WIN
QDir tempFileDir( "/tmp/qgis_map_serv" );
if ( !tempFileDir.exists() ) //make sure the directory exists
{
@ -54,7 +54,7 @@ QString QgsMSUtils::createTempFilePath()
currentDir.mkdir( "tmp" );
}
tempFilePath = QDir::currentPath() + "/tmp" + "/" + tempFileName;
#endif //WIN32
#endif // Q_OS_WIN
QFileInfo testFile( tempFilePath );
while ( testFile.exists() )

View File

@ -724,13 +724,13 @@ int QgsSOAPRequestHandler::setUrlToFile( QImage* img )
return 1;
}
#ifdef WIN32
#ifdef Q_OS_WIN
if ( !QFile::exists( QDir::currentPath() + "/tmp" ) )
{
QDir::current().mkdir( "tmp" );
}
tmpDir = QDir( QDir::currentPath() + "/tmp" );
#else //WIN32
#else // Q_OS_WIN
tmpDir = QDir( "/tmp" );
#endif

View File

@ -27,7 +27,7 @@
#include <stdio.h>
#include <stdlib.h>
#ifdef WIN32
#ifdef Q_OS_WIN
// Open files in binary mode
#include <fcntl.h> /* _O_BINARY */
#ifdef MSVC
@ -61,7 +61,7 @@ typedef SInt32 SRefCon;
#include "qgslogger.h"
/** print usage text
/** Print usage text
*/
void usage( std::string const & appName )
{
@ -112,13 +112,13 @@ static QStringList myFileList;
int main( int argc, char *argv[] )
{
#ifdef WIN32 // Windows
#ifdef Q_OS_WIN // Windows
#ifdef _MSC_VER
_set_fmode( _O_BINARY );
#else //MinGW
_fmode = _O_BINARY;
#endif // _MSC_VER
#endif // WIN32
#endif // Q_OS_WIN
/////////////////////////////////////////////////////////////////
// Command line options 'behaviour' flag setup
@ -152,7 +152,7 @@ int main( int argc, char *argv[] )
// user settings (~/.qgis) and it will be used for QSettings INI file
QString configpath;
#ifndef WIN32
#ifndef Q_OS_WIN
////////////////////////////////////////////////////////////////
// USe the GNU Getopts utility to parse cli arguments
// Invokes ctor `GetOpt (int argc, char **argv, char *optstring);'
@ -349,7 +349,7 @@ int main( int argc, char *argv[] )
myFileList.append( QDir::toNativeSeparators( QFileInfo( QFile::decodeName( argv[i] ) ).absoluteFilePath() ) );
}
}
#endif //WIN32
#endif // Q_OS_WIN
/////////////////////////////////////////////////////////////////////
// Now we have the handlers for the different behaviours...
@ -416,7 +416,7 @@ int main( int argc, char *argv[] )
gdalShares << QCoreApplication::applicationDirPath().append( "/share/gdal" )
<< appResources.append( "/share/gdal" )
<< appResources.append( "/gdal" );
Q_FOREACH ( const QString& gdalShare, gdalShares )
Q_FOREACH( const QString& gdalShare, gdalShares )
{
if ( QFile::exists( gdalShare ) )
{

View File

@ -23,24 +23,50 @@ MACRO (ADD_QGIS_GRASS_TEST grass_build_version testname testsrc)
qgis_core
qgisgrass${grass_build_version}
)
ADD_TEST(qgis_${testname}${grass_build_version} ${CMAKE_BINARY_DIR}/output/bin/qgis_${testname}${grass_build_version} -maxwarnings 10000)
IF (WIN32)
SET_PROPERTY(TEST qgis_${testname}${grass_build_version} PROPERTY
ENVIRONMENT "PATH=${GRASS_PREFIX${grass_build_version}}/lib;$ENV{PATH}"
)
ELSE (WIN32)
IF(WIN32 AND NOT USING_NMAKE)
FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${testname}.cmake
"
SET(ENV{PATH} \"${GRASS_PREFIX${grass_build_version}}/lib;${CMAKE_BINARY_DIR}/output/bin/\${CMAKE_BUILD_TYPE};${CMAKE_BINARY_DIR}/output/plugins/\${CMAKE_BUILD_TYPE};\$ENV{PATH}\")
MESSAGE(STATUS \"Running ${CMAKE_BINARY_DIR}/output/bin/\${CMAKE_BUILD_TYPE}/qgis_${testname}${grass_build_version}\")
EXECUTE_PROCESS(
COMMAND ${CMAKE_BINARY_DIR}/output/bin/\${CMAKE_BUILD_TYPE}/qgis_${testname}${grass_build_version}
RESULT_VARIABLE import_res
OUTPUT_VARIABLE import_output
ERROR_VARIABLE import_output
)
# Pass the output back to ctest
IF(import_output)
MESSAGE(" \${import_output} ")
ENDIF(import_output)
IF(import_res)
MESSAGE(SEND_ERROR " \${import_res} ")
ENDIF(import_res)
"
)
ADD_TEST(NAME qgis_${testname}${grass_build_version} COMMAND ${CMAKE_COMMAND} -D CMAKE_BUILD_TYPE=$<CONFIGURATION> -P ${CMAKE_CURRENT_BINARY_DIR}/${testname}.cmake)
ELSE (WIN32 AND NOT USING_NMAKE)
ADD_TEST(qgis_${testname}${grass_build_version} ${CMAKE_BINARY_DIR}/output/bin/qgis_${testname}${grass_build_version} -maxwarnings 10000)
ENDIF (WIN32 AND NOT USING_NMAKE)
IF(WIN32)
SET_PROPERTY(TEST qgis_${testname}${grass_build_version} PROPERTY ENVIRONMENT "GISBASE=${GRASS_PREFIX${grass_build_version}}")
IF (USING_NMAKE)
SET_PROPERTY(TEST qgis_${testname}${grass_build_version} PROPERTY
ENVIRONMENT "PATH=${GRASS_PREFIX${grass_build_version}}/lib;${CMAKE_BINARY_DIR}/output/bin;${CMAKE_BINARY_DIR}/output/plugins;$ENV{PATH}"
)
ENDIF (USING_NMAKE)
ELSE(WIN32)
IF (APPLE)
SET_PROPERTY(TEST qgis_${testname}${grass_build_version} PROPERTY
ENVIRONMENT "DYLD_LIBRARY_PATH=${GRASS_PREFIX${grass_build_version}}/lib:$ENV{DYLD_LIBRARY_PATH}"
)
ELSE (APPLE)
ELSE (APPLE)
# UNIX
SET_PROPERTY(TEST qgis_${testname}${grass_build_version} PROPERTY
ENVIRONMENT "LD_LIBRARY_PATH=${GRASS_PREFIX${grass_build_version}}/lib:$ENV{LD_LIBRARY_PATH}"
)
ENDIF (APPLE)
ENDIF (WIN32)
ENDMACRO (ADD_QGIS_GRASS_TEST)
MACRO (ADD_QGIS_GRASS_TESTS version)

View File

@ -66,7 +66,7 @@ class TestQgsGrassProvider: public QObject
void reportRow( QString message );
void reportHeader( QString message );
// verify result and report result
void verify( bool ok );
bool verify( bool ok );
// compare expected and got string and set ok to false if not equal
bool compare( QString expected, QString got, bool& ok );
// lists are considered equal if contains the same values regardless order
@ -81,6 +81,7 @@ class TestQgsGrassProvider: public QObject
QString mBuildMapset;
};
#define GVERIFY(x) QVERIFY( verify(x) )
void TestQgsGrassProvider::reportRow( QString message )
{
@ -108,7 +109,11 @@ void TestQgsGrassProvider::initTestCase()
mReport += QString( "<h1>GRASS %1 provider tests</h1>\n" ).arg( GRASS_BUILD_VERSION );
mReport += "<p>" + mySettings + "</p>\n";
#ifndef Q_OS_WIN
reportRow( "LD_LIBRARY_PATH: " + QString( getenv( "LD_LIBRARY_PATH" ) ) );
#else
reportRow( "PATH: " + QString( getenv( "PATH" ) ) );
#endif
QgsGrass::init();
@ -138,11 +143,11 @@ void TestQgsGrassProvider::cleanupTestCase()
//QgsApplication::exitQgis();
}
void TestQgsGrassProvider::verify( bool ok )
bool TestQgsGrassProvider::verify( bool ok )
{
reportRow( "" );
reportRow( QString( "Test result: " ) + ( ok ? "ok" : "error" ) );
QVERIFY( ok );
return ok;
}
bool TestQgsGrassProvider::compare( QString expected, QString got, bool &ok )
@ -199,7 +204,7 @@ void TestQgsGrassProvider::fatalError()
compare( errorMessage, e.what(), ok );
}
compare( errorMessage, QgsGrass::errorMessage(), ok );
verify( ok );
GVERIFY( ok );
}
void TestQgsGrassProvider::locations()
@ -212,7 +217,7 @@ void TestQgsGrassProvider::locations()
reportRow( "expectedLocations: " + expectedLocations.join( ", " ) );
reportRow( "locations: " + locations.join( ", " ) );
compare( expectedLocations, locations, ok );
verify( ok );
GVERIFY( ok );
}
void TestQgsGrassProvider::mapsets()
@ -274,7 +279,7 @@ void TestQgsGrassProvider::mapsets()
}
}
}
verify( ok );
GVERIFY( ok );
}
void TestQgsGrassProvider::maps()
@ -295,7 +300,7 @@ void TestQgsGrassProvider::maps()
reportRow( "expectedRasters: " + expectedRasters.join( ", " ) );
reportRow( "rasters: " + rasters.join( ", " ) );
compare( expectedRasters, rasters, ok );
verify( ok );
GVERIFY( ok );
}
void TestQgsGrassProvider::vectorLayers()
@ -322,7 +327,7 @@ void TestQgsGrassProvider::vectorLayers()
ok = false;
reportRow( QString( "ERROR: %1" ).arg( e.what() ) );
}
verify( ok );
GVERIFY( ok );
}
void TestQgsGrassProvider::region()
@ -352,7 +357,7 @@ void TestQgsGrassProvider::region()
reportRow( "regionCopy: " + regionCopy );
compare( expectedRegion, regionCopy, ok );
}
verify( ok );
GVERIFY( ok );
}
void TestQgsGrassProvider::info()
@ -408,7 +413,7 @@ void TestQgsGrassProvider::info()
ok = false;
}
verify( ok );
GVERIFY( ok );
}
// create temporary output location
@ -458,7 +463,7 @@ void TestQgsGrassProvider::rasterImport()
if ( !createTmpLocation( tmpGisdbase, tmpLocation, tmpMapset ) )
{
reportRow( "cannot create temporary location" );
verify( false );
GVERIFY( false );
return;
}
@ -515,7 +520,7 @@ void TestQgsGrassProvider::rasterImport()
delete import;
}
verify( ok );
GVERIFY( ok );
}
void TestQgsGrassProvider::vectorImport()
@ -530,7 +535,7 @@ void TestQgsGrassProvider::vectorImport()
if ( !createTmpLocation( tmpGisdbase, tmpLocation, tmpMapset ) )
{
reportRow( "cannot create temporary location" );
verify( false );
GVERIFY( false );
return;
}
@ -570,7 +575,7 @@ void TestQgsGrassProvider::vectorImport()
QStringList layers = QgsGrass::vectorLayers( tmpGisdbase, tmpLocation, tmpMapset, name );
reportRow( "created layers: " + layers.join( "," ) );
}
verify( ok );
GVERIFY( ok );
}
QTEST_MAIN( TestQgsGrassProvider )

View File

@ -38,7 +38,7 @@
#include <qgswcscapabilities.h>
#include <testqgswcspublicservers.h>
#ifdef WIN32
#ifdef Q_OS_WIN
// Open files in binary mode
#include <fcntl.h> /* _O_BINARY */
#ifdef MSVC
@ -875,13 +875,13 @@ void usage( std::string const & appName )
int main( int argc, char *argv[] )
{
#ifdef WIN32 // Windows
#ifdef Q_OS_WIN // Windows
#ifdef _MSC_VER
_set_fmode( _O_BINARY );
#else //MinGW
_fmode = _O_BINARY;
#endif // _MSC_VER
#endif // WIN32
#endif // Q_OS_WIN
QString myServer;
QString myCoverage;
@ -889,7 +889,7 @@ int main( int argc, char *argv[] )
int myMaxCoverages = 2;
bool myForce = false;
#ifndef WIN32
#ifndef Q_OS_WIN
int optionChar;
static struct option long_options[] =
{