gdal: Split tests into separate attributes

Makes it easier to run single tests for debugging purposes.

Co-authored-by: Robert Schütz <github@dotlambda.de>
This commit is contained in:
Victor Engmark 2024-02-21 11:59:38 +13:00
parent 3ce7f9e4f5
commit de01ad8151
No known key found for this signature in database
2 changed files with 32 additions and 26 deletions

View File

@ -270,9 +270,7 @@ stdenv.mkDerivation (finalAttrs: {
popd # autotest popd # autotest
''; '';
passthru.tests = { passthru.tests = callPackage ./tests.nix { gdal = finalAttrs.finalPackage; };
gdal = callPackage ./tests.nix { gdal = finalAttrs.finalPackage; };
};
__darwinAllowLocalNetworking = true; __darwinAllowLocalNetworking = true;

View File

@ -1,34 +1,40 @@
{ runCommand, gdal, jdk }: { runCommand, gdal, jdk, lib, testers }:
let let
inherit (gdal) pname version; inherit (gdal) pname version;
in in
runCommand "${pname}-tests" { meta.timeout = 60; } {
'' ogrinfo-version = testers.testVersion {
# test version package = gdal;
${gdal}/bin/ogrinfo --version \ command = "ogrinfo --version";
| grep 'GDAL ${version}' };
${gdal}/bin/gdalinfo --version \ gdalinfo-version = testers.testVersion {
| grep 'GDAL ${version}' package = gdal;
command = "gdalinfo --version";
};
ogrinfo-format-geopackage = runCommand "${pname}-ogrinfo-format-geopackage" { } ''
# test formats ${lib.getExe' gdal "ogrinfo"} --formats \
${gdal}/bin/ogrinfo --formats \
| grep 'GPKG.*GeoPackage' | grep 'GPKG.*GeoPackage'
touch $out
'';
${gdal}/bin/gdalinfo --formats \ gdalinfo-format-geotiff = runCommand "${pname}-gdalinfo-format-geotiff" { } ''
${lib.getExe' gdal "gdalinfo"} --formats \
| grep 'GTiff.*GeoTIFF' | grep 'GTiff.*GeoTIFF'
touch $out
'';
vector-file = runCommand "${pname}-vector-file" { } ''
# test vector file
echo -e "Latitude,Longitude,Name\n48.1,0.25,'Test point'" > test.csv echo -e "Latitude,Longitude,Name\n48.1,0.25,'Test point'" > test.csv
${gdal}/bin/ogrinfo ./test.csv ${lib.getExe' gdal "ogrinfo"} ./test.csv
touch $out
'';
raster-file = runCommand "${pname}-raster-file" { } ''
# test raster file ${lib.getExe' gdal "gdal_create"} \
${gdal}/bin/gdal_create \
-a_srs "EPSG:4326" \ -a_srs "EPSG:4326" \
-of GTiff \ -of GTiff \
-ot UInt16 \ -ot UInt16 \
@ -38,9 +44,11 @@ runCommand "${pname}-tests" { meta.timeout = 60; }
-co COMPRESS=LZW \ -co COMPRESS=LZW \
test.tif test.tif
${gdal}/bin/gdalinfo ./test.tif ${lib.getExe' gdal "gdalinfo"} ./test.tif
touch $out
'';
# test java bindings java-bindings = runCommand "${pname}-java-bindings" { } ''
cat <<EOF > main.java cat <<EOF > main.java
import org.gdal.gdal.gdal; import org.gdal.gdal.gdal;
class Main { class Main {
@ -49,7 +57,7 @@ runCommand "${pname}-tests" { meta.timeout = 60; }
} }
} }
EOF EOF
${jdk}/bin/java -Djava.library.path=${gdal}/lib/ -cp ${gdal}/share/java/gdal-${version}.jar main.java ${lib.getExe jdk} -Djava.library.path=${gdal}/lib/ -cp ${gdal}/share/java/gdal-${version}.jar main.java
touch $out touch $out
'' '';
}