gdal: add package tests
Co-authored-by: Sandro <sandro.jaeckel@gmail.com>
This commit is contained in:
parent
07382e73d0
commit
bfe4db82ae
|
@ -1,6 +1,8 @@
|
|||
{ lib
|
||||
, stdenv
|
||||
, callPackage
|
||||
, fetchFromGitHub
|
||||
|
||||
, bison
|
||||
, cmake
|
||||
, gtest
|
||||
|
@ -61,14 +63,14 @@
|
|||
, zstd
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
stdenv.mkDerivation (finalAttrs: {
|
||||
pname = "gdal";
|
||||
version = "3.7.1";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "OSGeo";
|
||||
repo = "gdal";
|
||||
rev = "v${version}";
|
||||
rev = "v${finalAttrs.version}";
|
||||
hash = "sha256-RXX21tCq0xJQli3NTertM9IweONrJfGeaFj3utMFjpM=";
|
||||
};
|
||||
|
||||
|
@ -89,7 +91,7 @@ stdenv.mkDerivation rec {
|
|||
"-DGEOTIFF_LIBRARY_RELEASE=${lib.getLib libgeotiff}/lib/libgeotiff${stdenv.hostPlatform.extensions.sharedLibrary}"
|
||||
"-DMYSQL_INCLUDE_DIR=${lib.getDev libmysqlclient}/include/mysql"
|
||||
"-DMYSQL_LIBRARY=${lib.getLib libmysqlclient}/lib/${lib.optionalString (libmysqlclient.pname != "mysql") "mysql/"}libmysqlclient${stdenv.hostPlatform.extensions.sharedLibrary}"
|
||||
] ++ lib.optionals doInstallCheck [
|
||||
] ++ lib.optionals finalAttrs.doInstallCheck [
|
||||
"-DBUILD_TESTING=ON"
|
||||
] ++ lib.optionals (!stdenv.isDarwin) [
|
||||
"-DCMAKE_SKIP_BUILD_RPATH=ON" # without, libgdal.so can't find libmariadb.so
|
||||
|
@ -213,14 +215,18 @@ stdenv.mkDerivation rec {
|
|||
popd # autotest
|
||||
'';
|
||||
|
||||
passthru.tests = {
|
||||
gdal = callPackage ./tests.nix { gdal = finalAttrs.finalPackage; };
|
||||
};
|
||||
|
||||
__darwinAllowLocalNetworking = true;
|
||||
|
||||
meta = with lib; {
|
||||
changelog = "https://github.com/OSGeo/gdal/blob/${src.rev}/NEWS.md";
|
||||
changelog = "https://github.com/OSGeo/gdal/blob/v${finalAttrs.version}/NEWS.md";
|
||||
description = "Translator library for raster geospatial data formats";
|
||||
homepage = "https://www.gdal.org/";
|
||||
license = licenses.mit;
|
||||
maintainers = with maintainers; teams.geospatial.members ++ [ marcweber dotlambda ];
|
||||
platforms = platforms.unix;
|
||||
};
|
||||
}
|
||||
})
|
||||
|
|
46
pkgs/development/libraries/gdal/tests.nix
Normal file
46
pkgs/development/libraries/gdal/tests.nix
Normal file
|
@ -0,0 +1,46 @@
|
|||
{ runCommand, gdal }:
|
||||
|
||||
let
|
||||
inherit (gdal) pname version;
|
||||
|
||||
in
|
||||
runCommand "${pname}-tests" {
|
||||
nativeBuildInputs = [ gdal ];
|
||||
meta.timeout = 60;
|
||||
} ''
|
||||
# test version
|
||||
ogrinfo --version \
|
||||
| grep 'GDAL ${version}'
|
||||
|
||||
gdalinfo --version \
|
||||
| grep 'GDAL ${version}'
|
||||
|
||||
|
||||
# test formats
|
||||
ogrinfo --formats \
|
||||
| grep 'GPKG.*GeoPackage'
|
||||
|
||||
gdalinfo --formats \
|
||||
| grep 'GTiff.*GeoTIFF'
|
||||
|
||||
|
||||
# test vector file
|
||||
echo -e "Latitude,Longitude,Name\n48.1,0.25,'Test point'" > test.csv
|
||||
ogrinfo ./test.csv
|
||||
|
||||
|
||||
# test raster file
|
||||
gdal_create \
|
||||
-a_srs "EPSG:4326" \
|
||||
-of GTiff \
|
||||
-ot UInt16 \
|
||||
-a_nodata 255 \
|
||||
-burn 0 \
|
||||
-outsize 800 600 \
|
||||
-co COMPRESS=LZW \
|
||||
test.tif
|
||||
|
||||
gdalinfo ./test.tif
|
||||
|
||||
touch $out
|
||||
''
|
Loading…
Reference in a new issue