From df79fbb8047f1860b91cf932ad79bcd46f6f949b Mon Sep 17 00:00:00 2001 From: "Simeon H.K. Fitch" Date: Wed, 28 Sep 2022 15:17:27 -0400 Subject: [PATCH] Linux test failure debugging. --- .github/workflows/ci.yml | 3 +++ CHANGES.md | 2 +- src/dataset.rs | 9 ++++++++- src/raster/tests.rs | 26 +++++++++++--------------- 4 files changed, 23 insertions(+), 17 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1a90fb904..f7f042874 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,6 +8,9 @@ on: # Allows you to run this workflow manually from the Actions tab workflow_dispatch: +env: + RUST_BACKTRACE: 1 + jobs: gdal_35: name: "ci gdal-35" diff --git a/CHANGES.md b/CHANGES.md index d68d6cf1e..1364cb663 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -30,7 +30,7 @@ - Added ability to set color table for bands with palette color interpretation. Added ability to create a color ramp (interpolated) color table. - - <> + - ## 0.13 diff --git a/src/dataset.rs b/src/dataset.rs index ce1f9cc40..a38f98290 100644 --- a/src/dataset.rs +++ b/src/dataset.rs @@ -19,10 +19,10 @@ use crate::{ Driver, Metadata, }; -use gdal_sys::OGRGeometryH; use gdal_sys::{ self, CPLErr, GDALAccess, GDALDatasetH, GDALMajorObjectH, OGRErr, OGRLayerH, OGRwkbGeometryType, }; +use gdal_sys::{GDALFlushCache, OGRGeometryH}; use libc::{c_double, c_int, c_uint}; #[cfg(all(major_ge_3, minor_ge_1))] @@ -400,6 +400,13 @@ impl Dataset { Ok(Dataset { c_dataset }) } + /// Flush all write cached data to disk. + /// + /// See [`GDALFlushCache`]. + pub fn flush_cache(&self) { + unsafe { GDALFlushCache(self.c_dataset) } + } + /// Creates a new Dataset by wrapping a C pointer /// /// # Safety diff --git a/src/raster/tests.rs b/src/raster/tests.rs index 492f3d725..7b84dae82 100644 --- a/src/raster/tests.rs +++ b/src/raster/tests.rs @@ -11,7 +11,6 @@ use crate::Driver; use gdal_sys::GDALDataType; use std::path::Path; -use crate::errors::GdalError; #[cfg(feature = "ndarray")] use ndarray::arr2; @@ -810,13 +809,13 @@ fn test_color_table() { } #[test] -fn test_create_color_table() -> crate::errors::Result<()> { +fn test_create_color_table() { let fixture = TempFixture::fixture("labels.tif"); // Open, modify, then close the base file. { - let dataset = Dataset::open(&fixture)?; + let dataset = Dataset::open(&fixture).unwrap(); assert_eq!(dataset.raster_count(), 1); - let mut band = dataset.rasterband(1)?; + let mut band = dataset.rasterband(1).unwrap(); assert_eq!(band.band_type(), GDALDataType::GDT_Byte); assert!(band.color_table().is_none()); @@ -831,31 +830,28 @@ fn test_create_color_table() -> crate::errors::Result<()> { assert_eq!(ct.entry(8), None); band.set_color_table(&ct); + dataset.flush_cache(); + drop(dataset); } // Reopen to confirm the changes. - let dataset = Dataset::open(&fixture)?; - let band = dataset.rasterband(1)?; - let ct = band - .color_table() - .ok_or_else(|| GdalError::BadArgument("missing color table".into()))?; + let dataset = Dataset::open(&fixture).unwrap(); + let band = dataset.rasterband(1).unwrap(); + let ct = band.color_table().expect("saved color table"); + assert_eq!(ct.entry_count(), 8); assert_eq!(ct.entry(0), Some(ColorEntry::rgba(0, 0, 0, 0))); assert_eq!(ct.entry(2), Some(ColorEntry::rgba(255, 0, 0, 255))); assert_eq!(ct.entry(8), None); - - Ok(()) } #[test] -fn test_color_ramp() -> crate::errors::Result<()> { - let ct = ColorTable::color_ramp(0, &ColorEntry::grey(0), 99, &ColorEntry::grey(99))?; +fn test_color_ramp() { + let ct = ColorTable::color_ramp(0, &ColorEntry::grey(0), 99, &ColorEntry::grey(99)).unwrap(); assert_eq!(ct.entry(0), Some(ColorEntry::grey(0))); assert_eq!(ct.entry(57), Some(ColorEntry::grey(57))); assert_eq!(ct.entry(99), Some(ColorEntry::grey(99))); assert_eq!(ct.entry(100), None); - - Ok(()) } #[test]