Skip to content

Commit

Permalink
Merge pull request #8728 from OSGeo/backport-8720-to-release/3.8
Browse files Browse the repository at this point in the history
[Backport release/3.8] gdal_sieve.py/gdalattachpct.py/gdalcompare.py/gdalmove.py: make sure --version and --help return 0 error code (fixes #8717)
  • Loading branch information
rouault authored Nov 17, 2023
2 parents 5c3ac19 + cbf4a2c commit 57f9d99
Show file tree
Hide file tree
Showing 20 changed files with 420 additions and 29 deletions.
22 changes: 22 additions & 0 deletions autotest/pyscripts/test_gdal2tiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,28 @@ def script_path():
return test_py_scripts.get_py_script("gdal2tiles")


###############################################################################
#


def test_gdal2tiles_help(script_path):

assert "ERROR" not in test_py_scripts.run_py_script(
script_path, "gdal2tiles", "--help"
)


###############################################################################
#


def test_gdal2tiles_version(script_path):

assert "ERROR" not in test_py_scripts.run_py_script(
script_path, "gdal2tiles", "--version"
)


def _verify_raster_band_checksums(filename, expected_cs=[]):
ds = gdal.Open(filename)
if ds is None:
Expand Down
22 changes: 22 additions & 0 deletions autotest/pyscripts/test_gdal2xyz.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,28 @@ def script_path():
return test_py_scripts.get_py_script("gdal2xyz")


###############################################################################
#


def test_gdal2xyz_help(script_path):

assert "ERROR" not in test_py_scripts.run_py_script(
script_path, "gdal2xyz", "--help"
)


###############################################################################
#


def test_gdal2xyz_version(script_path):

assert "ERROR" not in test_py_scripts.run_py_script(
script_path, "gdal2xyz", "--version"
)


def test_gdal2xyz_py_1():
"""test get_ovr_idx, create_flat_raster"""
pytest.importorskip("numpy")
Expand Down
22 changes: 22 additions & 0 deletions autotest/pyscripts/test_gdal_calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,28 @@ def script_path():
return test_py_scripts.get_py_script("gdal_calc")


###############################################################################
#


def test_gdal_calc_help(script_path):

assert "ERROR" not in test_py_scripts.run_py_script(
script_path, "gdal_calc", "--help"
)


###############################################################################
#


def test_gdal_calc_version(script_path):

assert "ERROR" not in test_py_scripts.run_py_script(
script_path, "gdal_calc", "--version"
)


# Usage: gdal_calc.py [-A <filename>] [--A_band] [-B...-Z filename] [other_options]


Expand Down
22 changes: 22 additions & 0 deletions autotest/pyscripts/test_gdal_edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,28 @@ def script_path():
# [-mo "META-TAG=VALUE"]* datasetname


###############################################################################
#


def test_gdal_edit_help(script_path):

assert "ERROR" not in test_py_scripts.run_py_script(
script_path, "gdal_edit", "--help"
)


###############################################################################
#


def test_gdal_edit_version(script_path):

assert "ERROR" not in test_py_scripts.run_py_script(
script_path, "gdal_edit", "--version"
)


###############################################################################
# Test -a_srs, -a_ullr, -a_nodata, -mo, -unit

Expand Down
22 changes: 22 additions & 0 deletions autotest/pyscripts/test_gdal_fillnodata.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,28 @@ def script_path():
return test_py_scripts.get_py_script("gdal_fillnodata")


###############################################################################
#


def test_gdal_fillnodata_help(script_path):

assert "ERROR" not in test_py_scripts.run_py_script(
script_path, "gdal_fillnodata", "--help"
)


###############################################################################
#


def test_gdal_fillnodata_version(script_path):

assert "ERROR" not in test_py_scripts.run_py_script(
script_path, "gdal_fillnodata", "--version"
)


###############################################################################
# Dummy test : there is no nodata value in the source dataset !

Expand Down
22 changes: 22 additions & 0 deletions autotest/pyscripts/test_gdal_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,28 @@ def sample_tifs(tmp_path_factory):
yield (sample1_tif, sample2_tif, sample3_tif, sample4_tif)


###############################################################################
#


def test_gdal_merge_help(script_path):

assert "ERROR" not in test_py_scripts.run_py_script(
script_path, "gdal_merge", "--help"
)


###############################################################################
#


def test_gdal_merge_version(script_path):

assert "ERROR" not in test_py_scripts.run_py_script(
script_path, "gdal_merge", "--version"
)


###############################################################################
# Basic test

Expand Down
22 changes: 22 additions & 0 deletions autotest/pyscripts/test_gdal_pansharpen.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,28 @@ def small_world_pan_tif(tmp_path_factory):
return small_world_pan_tif


###############################################################################
#


def test_gdal_pansharpen_help(script_path):

assert "ERROR" not in test_py_scripts.run_py_script(
script_path, "gdal_pansharpen", "--help"
)


###############################################################################
#


def test_gdal_pansharpen_version(script_path):

assert "ERROR" not in test_py_scripts.run_py_script(
script_path, "gdal_pansharpen", "--version"
)


###############################################################################
# Simple test

Expand Down
22 changes: 22 additions & 0 deletions autotest/pyscripts/test_gdal_polygonize.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,28 @@ def script_path():
return test_py_scripts.get_py_script("gdal_polygonize")


###############################################################################
#


def test_gdal_polygonize_help(script_path):

assert "ERROR" not in test_py_scripts.run_py_script(
script_path, "gdal_polygonize", "--help"
)


###############################################################################
#


def test_gdal_polygonize_version(script_path):

assert "ERROR" not in test_py_scripts.run_py_script(
script_path, "gdal_polygonize", "--version"
)


###############################################################################
# Test a fairly simple case, with nodata masking.

Expand Down
22 changes: 22 additions & 0 deletions autotest/pyscripts/test_gdal_proximity.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,28 @@ def script_path():
return test_py_scripts.get_py_script("gdal_proximity")


###############################################################################
#


def test_gdal_proximity_help(script_path):

assert "ERROR" not in test_py_scripts.run_py_script(
script_path, "gdal_proximity", "--help"
)


###############################################################################
#


def test_gdal_proximity_version(script_path):

assert "ERROR" not in test_py_scripts.run_py_script(
script_path, "gdal_proximity", "--version"
)


###############################################################################
# Test a fairly default case.

Expand Down
22 changes: 22 additions & 0 deletions autotest/pyscripts/test_gdal_retile.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,28 @@ def script_path():
return test_py_scripts.get_py_script("gdal_retile")


###############################################################################
#


def test_gdal_retile_help(script_path):

assert "ERROR" not in test_py_scripts.run_py_script(
script_path, "gdal_retile", "--help"
)


###############################################################################
#


def test_gdal_retile_version(script_path):

assert "ERROR" not in test_py_scripts.run_py_script(
script_path, "gdal_retile", "--version"
)


###############################################################################
# Test gdal_retile.py

Expand Down
22 changes: 22 additions & 0 deletions autotest/pyscripts/test_gdal_sieve.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,28 @@ def script_path():
return test_py_scripts.get_py_script("gdal_sieve")


###############################################################################
#


def test_gdal_sieve_help(script_path):

assert "ERROR" not in test_py_scripts.run_py_script(
script_path, "gdal_sieve", "--help"
)


###############################################################################
#


def test_gdal_sieve_version(script_path):

assert "ERROR" not in test_py_scripts.run_py_script(
script_path, "gdal_sieve", "--version"
)


###############################################################################
# Test a fairly default case.

Expand Down
22 changes: 22 additions & 0 deletions autotest/pyscripts/test_gdalcompare.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,28 @@ def source_filename(tmp_vsimem):
return filename


###############################################################################
#


def test_gdalcompare_help(script_path):

assert "ERROR" not in test_py_scripts.run_py_script(
script_path, "gdalcompare", "--help"
)


###############################################################################
#


def test_gdalcompare_version(script_path):

assert "ERROR" not in test_py_scripts.run_py_script(
script_path, "gdalcompare", "--version"
)


###############################################################################


Expand Down
22 changes: 22 additions & 0 deletions autotest/pyscripts/test_gdalmove.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,28 @@ def script_path():
#


def test_gdalmove_help(script_path):

assert "ERROR" not in test_py_scripts.run_py_script(
script_path, "gdalmove", "--help"
)


###############################################################################
#


def test_gdalmove_version(script_path):

assert "ERROR" not in test_py_scripts.run_py_script(
script_path, "gdalmove", "--version"
)


###############################################################################
#


def test_gdalmove_1(script_path):

shutil.copy(
Expand Down
Loading

0 comments on commit 57f9d99

Please sign in to comment.