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
'';
passthru.tests = {
gdal = callPackage ./tests.nix { gdal = finalAttrs.finalPackage; };
};
passthru.tests = callPackage ./tests.nix { gdal = finalAttrs.finalPackage; };
__darwinAllowLocalNetworking = true;

View File

@ -1,34 +1,40 @@
{ runCommand, gdal, jdk }:
{ runCommand, gdal, jdk, lib, testers }:
let
inherit (gdal) pname version;
in
runCommand "${pname}-tests" { meta.timeout = 60; }
''
# test version
${gdal}/bin/ogrinfo --version \
| grep 'GDAL ${version}'
{
ogrinfo-version = testers.testVersion {
package = gdal;
command = "ogrinfo --version";
};
${gdal}/bin/gdalinfo --version \
| grep 'GDAL ${version}'
gdalinfo-version = testers.testVersion {
package = gdal;
command = "gdalinfo --version";
};
# test formats
${gdal}/bin/ogrinfo --formats \
ogrinfo-format-geopackage = runCommand "${pname}-ogrinfo-format-geopackage" { } ''
${lib.getExe' gdal "ogrinfo"} --formats \
| 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'
touch $out
'';
# test vector file
vector-file = runCommand "${pname}-vector-file" { } ''
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
'';
# test raster file
${gdal}/bin/gdal_create \
raster-file = runCommand "${pname}-raster-file" { } ''
${lib.getExe' gdal "gdal_create"} \
-a_srs "EPSG:4326" \
-of GTiff \
-ot UInt16 \
@ -38,9 +44,11 @@ runCommand "${pname}-tests" { meta.timeout = 60; }
-co COMPRESS=LZW \
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
import org.gdal.gdal.gdal;
class Main {
@ -49,7 +57,7 @@ runCommand "${pname}-tests" { meta.timeout = 60; }
}
}
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
''
'';
}