Merge pull request #290298 from l0b0/gdal-test-separation

gdal: Split tests into separate attributes
This commit is contained in:
Robert Schütz 2024-02-22 05:21:59 +00:00 committed by GitHub
commit f433c05d56
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
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
''
'';
}