Description
Describe the bug
When there are no tests in the current directory or any of its subdirectories, the tests fails with traceback and error:
TypeError: '>=' not supported between instances of 'NoneType' and 'int'
This is because there is 0 files and the file_pass_per (percentage of files passing tests) is None which is a case which needs special handling, although it is still an failure.
To Reproduce
Compile latest GRASS GIS (or use 7.8) and:
grass --tmp-location XY --exec g.extension g.download.location
mkdir /tmp/grassdata
grass --tmp-location XY --exec g.download.location dbase=/tmp/grassdata url=https://grass.osgeo.org/sampledata/north_carolina/nc_spm_08_grass7.zip
cd grass/gis/source/code
mkdir /tmp/empty_dir
cd /tmp/empty_dir
grass --tmp-location XY --exec python3 -m grass.gunittest.main --grassdata /tmp/grassdata/ --location nc_spm_08_grass7 --location-type nc --min-success 80
where grass
is your installed/compiled GRASS GIS executable or a path to it and /tmp/
is where you want to work.
Expected behavior
Fail with non-zero return code like when the min success rate is not achieved, but without a traceback. Not finding any tests should be considered a failure. Optionally, there could be a new command line flag to consider that okay.
Screenshots
From (unrelated) #1342 (comment):
grass79 --tmp-location XY --exec python3 -m grass.gunittest.main --grassdata /tmp/grassdata/ --location nc_spm_08_grass7 --location-type nc --min-success 80
Starting GRASS GIS...
Creating new GRASS GIS location <tmploc>...
Cleaning up temporary files...
Executing <python3 -m grass.gunittest.main --grassdata /tmp/grassdata/ --location nc_spm_08_grass7 --location-type nc --min-success 80> ...
Executed 0 test files in 0:00:00.009054.
From them 0 files (unknown percentage) were successful and 0 files (unknown percentage) failed.
Traceback (most recent call last):
File "/usr/lib64/python3.9/runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib64/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/home/mneteler/software/grass_master/dist.x86_64-pc-linux-gnu/etc/python/grass/gunittest/main.py", line 227, in <module>
sys.exit(main())
File "/home/mneteler/software/grass_master/dist.x86_64-pc-linux-gnu/etc/python/grass/gunittest/main.py", line 221, in main
if reporter.file_pass_per >= args.min_success:
TypeError: '>=' not supported between instances of 'NoneType' and 'int'
System description (please complete the following information):
- GRASS GIS version 7.8 and development version
Additional context
Introduced with --min-success
(6962e31).