Skip to content

Commit

Permalink
tests: Revise content of the root testsuite dir (#4516)
Browse files Browse the repository at this point in the history
* Remove Makefiles.
* Move the functioning test to the testsuite directory for the gunittest to pick it up.
* Remove the extended example how to run gunittest. Point to the CI in the README instead.
* Remove hemisphere generator because it does not test anything by itself (without further processing and a human).
* Remove GPS import tests as the tools are not in core.
* Remove division into subdirectories. The directories with the code should be used instead.
* Improve the test for gunittest loader function with some duplication but now creating an overview of .py and .sh tests.
  • Loading branch information
wenzeslaus authored Oct 15, 2024
1 parent 1adbd2c commit 9a79aa4
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 277 deletions.
16 changes: 15 additions & 1 deletion python/grass/gunittest/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,4 +235,18 @@ def discover(self, start_dir, pattern="test*.py", top_level_dir=None):


if __name__ == "__main__":
GrassTestLoader().discover()
for expression in [r".*\.py$", r".*\.sh$"]:
modules = discover_modules(
start_dir=".",
grass_location="all",
file_regexp=expression,
skip_dirs=GrassTestLoader.skip_dirs,
testsuite_dir=GrassTestLoader.testsuite_dir,
all_locations_value=GrassTestLoader.all_tests_value,
universal_location_value=GrassTestLoader.universal_tests_value,
import_modules=False,
exclude=None,
)
print("Expression:", expression)
print(len(modules))
print([module.file_path for module in modules])
8 changes: 0 additions & 8 deletions testsuite/Makefile

This file was deleted.

44 changes: 27 additions & 17 deletions testsuite/README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,39 @@
# Test suite

This directory contains scripts to check some functionality of GRASS GIS.
Tests are in directories `tests` and `testsuite` under each directory which has tests.
This directory contains additional scripts and information to test functionality
without a focus on a specific part of the code.

GRASS GIS testsuite documentation: <https://grass.osgeo.org/grass-devel/manuals/libpython/gunittest_testing.html>
There are two testing mechanism in place, _pytest_ which is the modern way of testing
GRASS GIS. Tests using _pytest_ are written just as any other Python tests.

## Simple test data
In parallel, there is also custom unittest-based framework centered around
_grass.gunittest_ package. These tests run in the NC sample datasets and can be
executed using _pytest_ or directly. The unittest-based adds a number of custom
assert methods to accommodate different data and outputs typical in GRASS GIS.
_grass.gunittest_ documentation:
<https://grass.osgeo.org/grass-devel/manuals/libpython/gunittest_testing.html>

Some tests may be launched in the location `../demolocation/`:
## Running tests

Tests can be executed using _pytest_:

```bash
# create new mapset for test
grass ../demolocation/user1 -c
# run the test
make
# Setup the Python environment (if not set up already).
# Replace grass by path to the executable if not installed on path.
export PYTHONPATH=\$(grass --config python_path):\$PYTHONPATH
export LD_LIBRARY_PATH=\$(grass --config path)/lib:\$LD_LIBRARY_PATH
# Run the test.
pytest
```

## Extended test data

Most tests require the North Carolina Sample dataset, available from
<https://grass.osgeo.org/sampledata/north_carolina/>
## Test data

## Notes
To test manually or to write tests, you may need to use the North Carolina
Sample dataset, available from
<https://grass.osgeo.org/sampledata/north_carolina/>.

Since 2020: For a more advanced test suite, see
<https://github.com/OSGeo/grass/actions>
## CI

Until 2019: For a more advanced test suite, see
<http://fatra.cnr.ncsu.edu/grassgistests/summary_report/>
Most tests run in the CI. See the `.github` directory for details and
use it as a reference.
29 changes: 0 additions & 29 deletions testsuite/examples/test_framework_GRASS_GIS_with_NC.conf

This file was deleted.

144 changes: 0 additions & 144 deletions testsuite/examples/test_framework_GRASS_GIS_with_NC.sh

This file was deleted.

3 changes: 0 additions & 3 deletions testsuite/raster/Makefile

This file was deleted.

1 change: 0 additions & 1 deletion testsuite/raster/README

This file was deleted.

48 changes: 0 additions & 48 deletions testsuite/raster/rhemisphere.sh

This file was deleted.

File renamed without changes.
26 changes: 0 additions & 26 deletions testsuite/vector/v.in.gps_test.sh

This file was deleted.

0 comments on commit 9a79aa4

Please sign in to comment.