Skip to content

Commit

Permalink
backport test fixes (grass & delimited text provider)
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Jul 19, 2015
1 parent 15e5cf0 commit 166bcd4
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/providers/delimitedtext/qgsdelimitedtextfile.cpp
Expand Up @@ -20,6 +20,7 @@

#include <QtGlobal>
#include <QFile>
#include <QFileInfo>
#include <QDataStream>
#include <QTextStream>
#include <QFileSystemWatcher>
Expand Down Expand Up @@ -840,7 +841,6 @@ QgsDelimitedTextFile::Status QgsDelimitedTextFile::parseQuoted( QString &buffer,

bool QgsDelimitedTextFile::isValid()
{

return mDefinitionValid && QFile::exists( mFileName );
return mDefinitionValid && QFile::exists( mFileName ) && QFileInfo( mFileName ).size() > 0;
}

4 changes: 2 additions & 2 deletions src/providers/grass/qgis.d.rast.c
Expand Up @@ -29,6 +29,7 @@
#include <string.h>
#include <math.h>
#include <assert.h>
#include <limits.h>
#ifdef WIN32
#include <fcntl.h>
#include <io.h>
Expand Down Expand Up @@ -255,8 +256,7 @@ static int cell_draw( char *name,
// see comments in QgsGrassRasterProvider::noDataValue()
if ( data_type == CELL_TYPE )
{
//int nul = -2000000000;
int nul = -2147483648;
int nul = INT_MIN;
fwrite( &nul, 4, 1, fo );
}
else if ( data_type == DCELL_TYPE )
Expand Down
14 changes: 9 additions & 5 deletions src/providers/grass/qgsgrass.cpp
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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() )
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 ) );
Expand Down
15 changes: 12 additions & 3 deletions src/providers/grass/qgsgrass.h
Expand Up @@ -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. */
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/providers/grass/qgsgrassrasterprovider.cpp
Expand Up @@ -108,7 +108,7 @@ QgsGrassRasterProvider::QgsGrassRasterProvider( QString const & uri )
double myInternalNoDataValue;
if ( mGrassDataType == CELL_TYPE )
{
myInternalNoDataValue = -2147483648;
myInternalNoDataValue = INT_MIN;
}
else if ( mGrassDataType == DCELL_TYPE )
{
Expand Down
5 changes: 4 additions & 1 deletion tests/src/providers/grass/CMakeLists.txt
Expand Up @@ -26,8 +26,11 @@ MACRO (ADD_QGIS_GRASS_TEST grass_build_version testname testsrc)
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}\")
SET(ENV{PATH} \"${GRASS_PREFIX${grass_build_version}}/bin;${GRASS_PREFIX${grass_build_version}}/lib;${CMAKE_BINARY_DIR}/output/bin/\${CMAKE_BUILD_TYPE};${CMAKE_BINARY_DIR}/output/plugins/\${CMAKE_BUILD_TYPE};\$ENV{PATH}\")
SET(ENV{GISBASE} \"${GRASS_PREFIX${grass_build_version}}\")
MESSAGE(STATUS \"Running ${CMAKE_BINARY_DIR}/output/bin/\${CMAKE_BUILD_TYPE}/qgis_${testname}${grass_build_version}\")
MESSAGE(STATUS \"PATH:\$ENV{PATH}\")
MESSAGE(STATUS \"GISBASE:\$ENV{GISBASE}\")
EXECUTE_PROCESS(
COMMAND ${CMAKE_BINARY_DIR}/output/bin/\${CMAKE_BUILD_TYPE}/qgis_${testname}${grass_build_version}
RESULT_VARIABLE import_res
Expand Down

0 comments on commit 166bcd4

Please sign in to comment.