Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: Add xfail_windows decorator for failing tests on Windows #4362

Merged
merged 46 commits into from
Sep 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
34ad40d
grass.gunittest: Add xfail_windows decorator for Windows expected fai…
echoix Sep 18, 2024
8f9b9dd
lib/imagery: Add xfail_windows decorator to test functions
echoix Sep 18, 2024
0131b6e
Fix spacing issue in xfail_windows warning message
echoix Sep 19, 2024
f9f6553
Add stacklevel=2 to xfail_windows decorator warning message
echoix Sep 19, 2024
1064dff
Update utils.py
echoix Sep 19, 2024
a371541
Format end of file
echoix Sep 19, 2024
c2f9bdd
Comment out warning in decorator
echoix Sep 19, 2024
d48600c
Merge branch main into windows-xfail-gunittest
echoix Sep 19, 2024
e3d2b74
i.maxlik: Add xfail_windows decorator to SuccessTest class
echoix Sep 19, 2024
c039635
lib/gis: Add xfail_windows decorator to TestNewlinesWithGetlFunctions…
echoix Sep 19, 2024
87c317d
Update warning stacklevel to 3
echoix Sep 19, 2024
69cac23
Update utils.py
echoix Sep 19, 2024
ffac6b6
Update utils.py
echoix Sep 19, 2024
2abdcd0
Update utils.py
echoix Sep 19, 2024
30cd437
Merge branch 'main' into windows-xfail-gunittest
echoix Sep 19, 2024
f892eb7
tests: Add expected failures to failing tests on windows
echoix Sep 19, 2024
b2f71f6
tests: Apply xfail_windows decorator to setUpClass in lib/gis getl tests
echoix Sep 19, 2024
7c0773d
tests: Apply xfail_windows decorator to parser json tests in lib/gis
echoix Sep 19, 2024
9d370b7
tests: Apply xfail_windows decorator to failing test in lib/imagery
echoix Sep 19, 2024
9e764d0
Remove wrong import of xfail_windows
echoix Sep 19, 2024
20eb947
tests: Temporarily remove all gunittest exclusions
echoix Sep 19, 2024
e220246
Merge branch 'main' into windows-xfail-gunittest
echoix Sep 21, 2024
d55ba68
tests: Apply xfail_windows decorator to failing test in test_gcmd.py
echoix Sep 21, 2024
960befe
tests: Apply xfail_windows decorator to failing test in lib/init in t…
echoix Sep 21, 2024
e33dfce
CI(OSGeo4W): Use an OSGeo4W-specific gunittest.cfg config file
echoix Sep 21, 2024
c9599fc
Revert "tests: Temporarily remove all gunittest exclusions"
echoix Sep 21, 2024
2221cbc
v.out.lidar: Apply xfail_windows decorator to one failing test
echoix Sep 21, 2024
a499573
t.rast.series: Apply xfail_windows decorator to failing tests
echoix Sep 21, 2024
2dc4d80
t.connect: Apply xfail_windows decorator to three failing tests
echoix Sep 21, 2024
9fff0ef
g.search.modules: Apply xfail_windows decorator to a failing test
echoix Sep 21, 2024
1c5a426
grass.temporal: Apply xfail_windows decorator to failing tests in uni…
echoix Sep 21, 2024
3a30a57
grass.gunittest: Apply xfail_windows decorator to failing test test_a…
echoix Sep 21, 2024
aa3ff5e
tests: Re-enable excluded tests that are not failing on Windows
echoix Sep 21, 2024
2d488ee
tests: Re-enable passing tests from .gunittest.cfg exclusion list
echoix Sep 21, 2024
e14e3b2
Update test_gis_lib_getl.py
echoix Sep 21, 2024
362e9fe
Update test_raster_img.py
echoix Sep 21, 2024
10a7d67
tests: Try re-enabling python/grass/script/testsuite/test_script_doct…
echoix Sep 21, 2024
4108192
i.maxlik: Add xfail_windows decorator to all tests in class
echoix Sep 21, 2024
877c7c4
tests: Exclude more tests that are failing on Windows
echoix Sep 21, 2024
63e7d66
v.univar: Apply xfail_windows decorator to failing tests
echoix Sep 21, 2024
3c65184
t.rast.univar: Apply xfail_windows decorator to a failing test
echoix Sep 21, 2024
4a0a546
r.in.gdal: Try avoiding error in calling gdal-config in skipif decora…
echoix Sep 21, 2024
6d1dad4
CI(OSGeo4W): Increase min-success to 96% for gunittest
echoix Sep 21, 2024
a15815a
Merge branch 'main' into windows-xfail-gunittest
echoix Sep 21, 2024
3522482
Add line in test_grass_tmp_mapset.py
echoix Sep 22, 2024
7c6c75c
Update test_r_tileset.py
echoix Sep 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/osgeo4w_gunittest.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[gunittest]

# Files (or wildcard patterns) to exclude from testing separated by newline or
# space. This would be ideally empty or it would include just special cases,
# but it includes mainly tests which can (and should) be fixed.
exclude =
gui/wxpython/core/testsuite/toolboxes.sh
lib/init/testsuite/test_grass_tmp_mapset.py
python/grass/gunittest/testsuite/test_gunitest_doctests.py
python/grass/pygrass/raster/testsuite/test_pygrass_raster_doctests.py
python/grass/pygrass/rpc/testsuite/test_pygrass_rpc_doctests.py
python/grass/script/testsuite/test_script_doctests.py
python/grass/temporal/testsuite/unittests_temporal_raster_conditionals_complement_else.py
temporal/t.info/testsuite/test.t.info.sh
temporal/t.rast.accdetect/testsuite/test.t.rast.accdetect.reverse.sh
temporal/t.rast.accdetect/testsuite/test.t.rast.accdetect.sh
temporal/t.rast.aggregate/testsuite/test_aggregation_relative.py
vector/v.edit/testsuite/select_all_flag.sh
vector/v.in.lidar/testsuite/decimation_test.py
vector/v.in.lidar/testsuite/mask_test.py
vector/v.in.lidar/testsuite/test_v_in_lidar_basic.py
vector/v.in.lidar/testsuite/test_v_in_lidar_filter.py
vector/v.what.rast3/testsuite/test.v.what.rast3.sh
vector/v.what/testsuite/test_vwhat_layers.py
vector/v.what/testsuite/test_vwhat_ncspm.py

# Maximum time for execution of one test file (not a test function)
# after which test is terminated (which may not terminate child processes
# from that test).
# Using 5 minutes as maximum (average test time should be much shorter,
# couple seconds per file, median should be around one second).
timeout = 300
2 changes: 1 addition & 1 deletion .github/workflows/test_thorough.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ set grass=%1
set python=%2

call %grass% --tmp-project XY --exec g.download.project url=https://grass.osgeo.org/sampledata/north_carolina/nc_spm_full_v2alpha2.tar.gz path=%USERPROFILE%
call %grass% --tmp-project XY --exec %python% -m grass.gunittest.main --grassdata %USERPROFILE% --location nc_spm_full_v2alpha2 --location-type nc --min-success 86
call %grass% --tmp-project XY --exec %python% -m grass.gunittest.main --grassdata %USERPROFILE% --location nc_spm_full_v2alpha2 --location-type nc --min-success 96 --config .github\workflows\osgeo4w_gunittest.cfg
3 changes: 3 additions & 0 deletions gui/wxpython/core/testsuite/test_gcmd.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from grass.gunittest.case import TestCase
from grass.gunittest.main import test
from grass.gunittest.utils import xfail_windows


class Rcv:
Expand All @@ -16,6 +17,8 @@ def recv(self):


class Recv_SomeTest(TestCase):

@xfail_windows
def test_decode(self):
"""
Multibyte chars should not be split
Expand Down
3 changes: 3 additions & 0 deletions imagery/i.maxlik/testsuite/test_i_maxlik.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

from grass.gunittest.case import TestCase
from grass.gunittest.main import test
from grass.gunittest.utils import xfail_windows

from grass.lib.gis import G_mapset_path
from grass.lib.raster import Rast_write_semantic_label
Expand Down Expand Up @@ -172,6 +173,7 @@ def tearDownClass(cls):
)
cls.runModule("g.remove", flags="f", type="group", name=cls.group, quiet=True)

@xfail_windows
def test_v1(self):
"""Test v1 signature"""
self.assertModule(
Expand All @@ -193,6 +195,7 @@ def test_v1(self):
self.assertEqual(res.get_cat(0)[1], 1)
res.close()

@xfail_windows
def test_v2(self):
"""Test v2 signature"""
self.assertModule(
Expand Down
5 changes: 5 additions & 0 deletions lib/gis/testsuite/test_parser_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@

import subprocess
from grass.gunittest.case import TestCase
from grass.gunittest.utils import xfail_windows
from grass.script import decode
import json


class TestParserJson(TestCase):

@xfail_windows
def test_r_slope_aspect_json(self):
args = [
"r.slope.aspect",
Expand Down Expand Up @@ -58,6 +61,7 @@ def test_r_slope_aspect_json(self):
self.assertEqual(json_code["inputs"], inputs)
self.assertEqual(json_code["outputs"], outputs)

@xfail_windows
def test_v_out_ascii(self):
args = [
"v.out.ascii",
Expand Down Expand Up @@ -91,6 +95,7 @@ def test_v_out_ascii(self):
self.assertEqual(json_code["inputs"], inputs)
self.assertEqual(json_code["outputs"], outputs)

@xfail_windows
def test_v_info(self):
args = ["v.info", "map=hospitals@PERMANENT", "-c", "--json"]

Expand Down
4 changes: 4 additions & 0 deletions lib/imagery/testsuite/test_imagery_signature_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

from grass.gunittest.case import TestCase
from grass.gunittest.main import test
from grass.gunittest.utils import xfail_windows

from grass.script.core import tempname
import grass.script as gs
Expand Down Expand Up @@ -44,16 +45,19 @@


class GetSignaturesDirTestCase(TestCase):
@xfail_windows
def test_get_sig(self):
cdir = ctypes.create_string_buffer(GNAME_MAX)
I_get_signatures_dir(cdir, I_SIGFILE_TYPE_SIG)
self.assertEqual(utils.decode(cdir.value), f"signatures{HOST_DIRSEP}sig")

@xfail_windows
def test_get_sigset(self):
cdir = ctypes.create_string_buffer(GNAME_MAX)
I_get_signatures_dir(cdir, I_SIGFILE_TYPE_SIGSET)
self.assertEqual(utils.decode(cdir.value), f"signatures{HOST_DIRSEP}sigset")

@xfail_windows
def test_get_libsvm(self):
elem = ctypes.create_string_buffer(GNAME_MAX)
I_get_signatures_dir(elem, I_SIGFILE_TYPE_LIBSVM)
Expand Down
5 changes: 5 additions & 0 deletions lib/init/testsuite/test_grass_tmp_mapset.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import os
import shutil
import subprocess
from grass.gunittest.utils import xfail_windows


# Note that unlike rest of GRASS GIS, here we are using unittest package
Expand All @@ -43,6 +44,7 @@ def tearDown(self):
"""Deletes the location"""
shutil.rmtree(self.location, ignore_errors=True)

@xfail_windows
def test_command_runs(self):
"""Check that correct parameters are accepted"""
return_code = subprocess.call(
Expand All @@ -57,6 +59,7 @@ def test_command_runs(self):
),
)

@xfail_windows
def test_command_fails_without_location(self):
"""Check that the command fails with a nonexistent location"""
return_code = subprocess.call(
Expand All @@ -78,6 +81,7 @@ def test_command_fails_without_location(self):
),
)

@xfail_windows
def test_mapset_metadata_correct(self):
"""Check that metadata is readable and have expected value (XY CRS)"""
output = subprocess.check_output(
Expand All @@ -91,6 +95,7 @@ def test_mapset_metadata_correct(self):
),
)

@xfail_windows
def test_mapset_deleted(self):
"""Check that mapset is deleted at the end of execution"""
subprocess.check_call(
Expand Down
5 changes: 5 additions & 0 deletions python/grass/grassdb/testsuite/test_manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from grass.gunittest.case import TestCase
from grass.gunittest.gmodules import call_module
from grass.gunittest.main import test
from grass.gunittest.utils import xfail_windows


class TestMapsetPath(TestCase):
Expand All @@ -38,6 +39,7 @@ def test_mapset_from_path_object(self):
self.assertEqual(mapset_path.mapset, mapset_name)
self.assertEqual(mapset_path.path, Path(path) / location_name / mapset_name)

@xfail_windows
def test_mapset_from_str(self):
"""Check with path from str and database directory as Path"""
path = "does/not/exist"
Expand All @@ -60,6 +62,7 @@ def test_mapset_from_str(self):
class TestSplitMapsetPath(TestCase):
"""Check that split works with different parameters"""

@xfail_windows
def test_split_path(self):
"""Check that pathlib.Path is correctly split"""
ref_db = "does/not/exist"
Expand All @@ -71,6 +74,7 @@ def test_split_path(self):
self.assertEqual(new_location, ref_location)
self.assertEqual(new_mapset, ref_mapset)

@xfail_windows
def test_split_str(self):
"""Check that path as str is correctly split"""
ref_db = "does/not/exist"
Expand All @@ -82,6 +86,7 @@ def test_split_str(self):
self.assertEqual(new_location, ref_location)
self.assertEqual(new_mapset, ref_mapset)

@xfail_windows
def test_split_str_trailing_slash(self):
"""Check that path as str with a trailing slash is correctly split"""
ref_db = "does/not/exist"
Expand Down
3 changes: 3 additions & 0 deletions python/grass/gunittest/testsuite/test_assertions.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from grass.gunittest.case import TestCase
from grass.gunittest.main import test
from grass.gunittest.gmodules import SimpleModule
from grass.gunittest.utils import xfail_windows


class TestTextAssertions(TestCase):
Expand All @@ -34,6 +35,7 @@ def test_assertLooksLike(self):
def test_assertLooksLike_multiline(self):
self.assertLooksLike("a=123\nb=456\nc=789", "a=...\nb=...\nc=...")

@xfail_windows
def test_assertLooksLike_multiline_platform_dependent(self):
self.assertLooksLike(
"a=123\nb=456\nc=789", "a=...{nl}b=...{nl}c=...".format(nl=os.linesep)
Expand Down Expand Up @@ -384,6 +386,7 @@ def test_assertFileExists_empty_file(self):
self.failureException, self.assertFileExists, filename=self.emtpy_file
)

@xfail_windows
def test_assertFileMd5(self):
self.assertFileMd5(filename=self.file_with_md5, md5=self.file_md5)
self.assertRaises(
Expand Down
2 changes: 2 additions & 0 deletions python/grass/gunittest/testsuite/test_assertions_vect.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from grass.exceptions import CalledModuleError
from grass.gunittest.case import TestCase
from grass.gunittest.main import test
from grass.gunittest.utils import xfail_windows


V_UNIVAR_SCHOOLS_WIDTH_SUBSET = """n=144
Expand Down Expand Up @@ -281,6 +282,7 @@ def test_assertVectorAsciiEqualsVectorAscii_diff_content(self):
self.assertFileExists(self.simple_base_file)
self.assertFileExists(self.simple_modified_file)

@xfail_windows
def test_assertVectorEqualsAscii_by_import(self):
amap = "simple_vector_map_imported_base"
self.runModule(
Expand Down
2 changes: 2 additions & 0 deletions python/grass/gunittest/testsuite/test_checkers.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
file_md5,
text_file_md5,
)
from grass.gunittest.utils import xfail_windows


class TestValuesEqual(TestCase):
Expand Down Expand Up @@ -386,6 +387,7 @@ def tearDownClass(cls):
try_remove(cls.correct_file_name_unix_nl)
try_remove(cls.wrong_file_name)

@xfail_windows
def test_text_file_binary(self):
r"""File with ``\n`` (LF) newlines as binary (MD5 has ``\n``)."""
self.assertEqual(
Expand Down
16 changes: 16 additions & 0 deletions python/grass/gunittest/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
from pathlib import Path
import shutil
import sys
from unittest import expectedFailure
import warnings


def ensure_dir(directory):
Expand Down Expand Up @@ -80,3 +82,17 @@ def safe_repr(obj, short=False):
if not short or len(result) < _MAX_LENGTH:
return result
return result[:_MAX_LENGTH] + " [truncated]..."


def xfail_windows(test_item):
"""Marks a test as an expected failure or error only on Windows
Equivalent to applying @unittest.expectedFailure only when running
on Windows.
"""
if not sys.platform.startswith("win"):
return lambda func: func
warnings.warn(
"Once the test is fixed and passing, remove the @xfail_windows decorator",
stacklevel=2,
)
echoix marked this conversation as resolved.
Show resolved Hide resolved
return expectedFailure(test_item)
5 changes: 5 additions & 0 deletions python/grass/jupyter/testsuite/map3d_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import grass.jupyter as gj
from grass.gunittest.case import TestCase
from grass.gunittest.main import test
from grass.gunittest.utils import xfail_windows


def can_import_ipython():
Expand Down Expand Up @@ -81,12 +82,14 @@ def tearDown(self):
else:
file.unlink(missing_ok=True)

@xfail_windows
def test_defaults(self):
"""Check that default settings work"""
renderer = gj.Map3D()
renderer.render(elevation_map="elevation", color_map="elevation")
self.assertFileExists(renderer.filename)

@xfail_windows
def test_filename(self):
"""Check that custom filename works"""
custom_filename = "test_filename.png"
Expand All @@ -96,12 +99,14 @@ def test_filename(self):
renderer.render(elevation_map="elevation", color_map="elevation")
self.assertFileExists(custom_filename)

@xfail_windows
def test_hw(self):
"""Check that custom width and height works"""
renderer = gj.Map3D(width=200, height=400)
renderer.render(elevation_map="elevation", color_map="elevation")
self.assertFileExists(renderer.filename)

@xfail_windows
def test_overlay(self):
"""Check that overlay works"""
renderer = gj.Map3D()
Expand Down
2 changes: 2 additions & 0 deletions python/grass/pygrass/raster/testsuite/test_category.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from grass.gunittest.case import TestCase
from grass.gunittest.main import test
from grass.gunittest.utils import xfail_windows

from grass.pygrass.raster import RasterRow
from grass.pygrass.raster.category import Category
Expand Down Expand Up @@ -76,6 +77,7 @@ def testFirstCat(self):
self.assertEqual(cats[7], cat7)
self.assertEqual(cats[15], cat15)

@xfail_windows
def testWrite(self):
tmpfile = tempfile(False)
cats = Category(self.name)
Expand Down
2 changes: 2 additions & 0 deletions python/grass/pygrass/raster/testsuite/test_numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from grass.gunittest.case import TestCase
from grass.gunittest.main import test
from grass.gunittest.utils import xfail_windows
from numpy.random import default_rng
from grass.pygrass.raster import raster2numpy, numpy2raster, RasterRow

Expand Down Expand Up @@ -48,6 +49,7 @@ def test_len(self):
self.assertTrue(len(self.numpy_obj), 40)
self.assertTrue(len(self.numpy_obj[0]), 60)

@xfail_windows
def test_write(self):
rng = default_rng()
numpy2raster(rng.random([40, 60]), "FCELL", self.name, True)
Expand Down
Loading
Loading